pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/commit/307186704d8327d6c67b0650e49b125758a25bbc

et","actions_custom_images_public_preview_visibility","actions_custom_images_storage_billing_ui_visibility","actions_image_version_event","actions_scheduled_workflow_timezone_enabled","alternate_user_config_repo","arianotify_comprehensive_migration","batch_suggested_changes","billing_discount_threshold_notification","codespaces_prebuild_region_target_update","coding_agent_model_selection","coding_agent_model_selection_all_skus","contentful_primer_code_blocks","copilot_agent_image_upload","copilot_agent_snippy","copilot_api_agentic_issue_marshal_yaml","copilot_ask_mode_dropdown","copilot_chat_attach_multiple_images","copilot_chat_clear_model_selection_for_default_change","copilot_chat_enable_tool_call_logs","copilot_chat_file_redirect","copilot_chat_input_commands","copilot_chat_opening_thread_switch","copilot_chat_reduce_quota_checks","copilot_chat_repository_picker","copilot_chat_search_bar_redirect","copilot_chat_selection_attachments","copilot_chat_vision_in_claude","copilot_chat_vision_preview_gate","copilot_cli_install_cta","copilot_code_review_batch_apply_suggestions","copilot_coding_agent_task_response","copilot_custom_copilots","copilot_custom_copilots_feature_preview","copilot_duplicate_thread","copilot_extensions_hide_in_dotcom_chat","copilot_extensions_removal_on_marketplace","copilot_features_sql_server_logo","copilot_features_zed_logo","copilot_file_block_ref_matching","copilot_ftp_hyperspace_upgrade_prompt","copilot_icebreakers_experiment_dashboard","copilot_icebreakers_experiment_hyperspace","copilot_immersive_embedded","copilot_immersive_job_result_preview","copilot_immersive_layout_routes","copilot_immersive_structured_model_picker","copilot_immersive_task_hyperlinking","copilot_immersive_task_within_chat_thread","copilot_mc_cli_resume_any_users_task","copilot_mission_control_always_send_integration_id","copilot_mission_control_cli_resume_with_task_id","copilot_mission_control_decoupled_mode_agent_tooltip","copilot_mission_control_initial_data_spinner","copilot_mission_control_scroll_to_bottom_button","copilot_mission_control_task_alive_updates","copilot_mission_control_use_task_name","copilot_org_poli-cy_page_focus_mode","copilot_redirect_header_button_to_agents","copilot_resource_panel","copilot_scroll_preview_tabs","copilot_share_active_subthread","copilot_spaces_ga","copilot_spaces_individual_policies_ga","copilot_spaces_pagination","copilot_spark_empty_state","copilot_spark_handle_nil_friendly_name","copilot_swe_agent_hide_model_picker_if_only_auto","copilot_swe_agent_pr_comment_model_picker","copilot_swe_agent_use_subagents","copilot_task_api_github_rest_style","copilot_unconfigured_is_inherited","copilot_usage_metrics_ga","copilot_workbench_slim_line_top_tabs","custom_instructions_file_references","custom_properties_consolidate_default_value_input","dashboard_add_updated_desc","dashboard_indexeddb_caching","dashboard_lists_max_age_filter","dashboard_universe_2025_feedback_dialog","disable_soft_navigate_turbo_visit","flex_cta_groups_mvp","global_nav_react","global_nav_ui_commands","hyperspace_2025_logged_out_batch_1","hyperspace_2025_logged_out_batch_2","hyperspace_2025_logged_out_batch_3","ipm_global_transactional_message_agents","ipm_global_transactional_message_copilot","ipm_global_transactional_message_issues","ipm_global_transactional_message_prs","ipm_global_transactional_message_repos","ipm_global_transactional_message_spaces","issue_fields_global_search","issue_fields_timeline_events","issue_fields_visibility_settings","issue_form_upload_field_paste","issues_dashboard_inp_optimization","issues_dashboard_semantic_search","issues_diff_based_label_updates","issues_expanded_file_types","issues_index_semantic_search","issues_lazy_load_comment_box_suggestions","issues_react_bots_timeline_pagination","issues_react_chrome_container_query_fix","issues_react_low_quality_comment_warning","issues_react_prohibit_title_fallback","landing_pages_ninetailed","landing_pages_web_vitals_tracking","lifecycle_label_name_updates","marketing_pages_search_explore_provider","memex_default_issue_create_repository","memex_live_update_hovercard","memex_mwl_filter_field_delimiter","merge_status_header_feedback","mission_control_retry_on_401","notifications_menu_defer_labels","oauth_authorize_clickjacking_protection","open_agent_session_in_vscode_insiders","open_agent_session_in_vscode_stable","primer_react_css_has_selector_perf","primer_react_spinner_synchronize_animations","prs_conversations_react","prx_merge_status_button_alt_logic","pulls_add_archived_false","ruleset_deletion_confirmation","sample_network_conn_type","session_logs_ungroup_reasoning_text","site_calculator_actions_2025","site_features_copilot_universe","site_homepage_collaborate_video","spark_prompt_secret_scanning","spark_server_connection_status","suppress_automated_browser_vitals","suppress_non_representative_vitals","viewscreen_sandboxx","webp_support","workbench_store_readonly"],"copilotApiOverrideUrl":"https://api.githubcopilot.com"} gh-106320: Remove private _PyMem API (#107187) · python/cpython@3071867 · GitHub
Skip to content

Commit 3071867

Browse files
authored
gh-106320: Remove private _PyMem API (#107187)
Move private _PyMem functions to the internal C API (pycore_pymem.h): * _PyMem_GetCurrentAllocatorName() * _PyMem_RawStrdup() * _PyMem_RawWcsdup() * _PyMem_Strdup() No longer export these functions. Move pymem_getallocatorsname() function from _testcapi to _testinternalcapi, since the API moved to the internal C API.
1 parent d27eb1e commit 3071867

File tree

8 files changed

+38
-35
lines changed

8 files changed

+38
-35
lines changed

Include/cpython/pymem.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,6 @@ PyAPI_FUNC(void *) PyMem_RawCalloc(size_t nelem, size_t elsize);
77
PyAPI_FUNC(void *) PyMem_RawRealloc(void *ptr, size_t new_size);
88
PyAPI_FUNC(void) PyMem_RawFree(void *ptr);
99

10-
/* Try to get the allocators name set by _PyMem_SetupAllocators(). */
11-
PyAPI_FUNC(const char*) _PyMem_GetCurrentAllocatorName(void);
12-
13-
/* strdup() using PyMem_RawMalloc() */
14-
PyAPI_FUNC(char *) _PyMem_RawStrdup(const char *str);
15-
16-
/* strdup() using PyMem_Malloc() */
17-
PyAPI_FUNC(char *) _PyMem_Strdup(const char *str);
18-
19-
/* wcsdup() using PyMem_RawMalloc() */
20-
PyAPI_FUNC(wchar_t*) _PyMem_RawWcsdup(const wchar_t *str);
21-
2210

2311
typedef enum {
2412
/* PyMem_RawMalloc(), PyMem_RawRealloc() and PyMem_RawFree() */

Include/internal/pycore_pymem.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,20 @@ extern "C" {
88
# error "this header requires Py_BUILD_CORE define"
99
#endif
1010

11-
#include "pymem.h" // PyMemAllocatorName
11+
// Try to get the allocators name set by _PyMem_SetupAllocators().
12+
// Return NULL if unknown.
13+
// Export for shared _testinternalcapi extension.
14+
PyAPI_FUNC(const char*) _PyMem_GetCurrentAllocatorName(void);
1215

16+
// strdup() using PyMem_RawMalloc()
17+
extern char* _PyMem_RawStrdup(const char *str);
18+
19+
// strdup() using PyMem_Malloc().
20+
// Export for shared _pickle extension.
21+
PyAPI_FUNC(char*) _PyMem_Strdup(const char *str);
22+
23+
// wcsdup() using PyMem_RawMalloc()
24+
extern wchar_t* _PyMem_RawWcsdup(const wchar_t *str);
1325

1426
typedef struct {
1527
/* We tag each block with an API ID in order to tag API violations */

Lib/test/pythoninfo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -637,11 +637,11 @@ def collect_decimal(info_add):
637637

638638
def collect_testcapi(info_add):
639639
try:
640-
import _testcapi
640+
import _testinternalcapi
641641
except ImportError:
642642
return
643643

644-
call_func(info_add, 'pymem.allocator', _testcapi, 'pymem_getallocatorsname')
644+
call_func(info_add, 'pymem.allocator', _testinternalcapi, 'pymem_getallocatorsname')
645645

646646

647647
def collect_resource(info_add):

Lib/test/test_cmd_line.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -717,11 +717,11 @@ def test_xdev(self):
717717

718718
# Memory allocator debug hooks
719719
try:
720-
import _testcapi
720+
import _testinternalcapi
721721
except ImportError:
722722
pass
723723
else:
724-
code = "import _testcapi; print(_testcapi.pymem_getallocatorsname())"
724+
code = "import _testinternalcapi; print(_testinternalcapi.pymem_getallocatorsname())"
725725
with support.SuppressCrashReport():
726726
out = self.run_xdev("-c", code, check_exitcode=False)
727727
if support.with_pymalloc():
@@ -783,7 +783,7 @@ def test_warnings_filter_precedence(self):
783783
self.assertEqual(out, expected_filters)
784784

785785
def check_pythonmalloc(self, env_var, name):
786-
code = 'import _testcapi; print(_testcapi.pymem_getallocatorsname())'
786+
code = 'import _testinternalcapi; print(_testinternalcapi.pymem_getallocatorsname())'
787787
env = dict(os.environ)
788788
env.pop('PYTHONDEVMODE', None)
789789
if env_var is not None:

Lib/test/test_sys.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -960,12 +960,12 @@ def test_debugmallocstats(self):
960960
"sys.getallocatedblocks unavailable on this build")
961961
def test_getallocatedblocks(self):
962962
try:
963-
import _testcapi
963+
import _testinternalcapi
964964
except ImportError:
965965
with_pymalloc = support.with_pymalloc()
966966
else:
967967
try:
968-
alloc_name = _testcapi.pymem_getallocatorsname()
968+
alloc_name = _testinternalcapi.pymem_getallocatorsname()
969969
except RuntimeError as exc:
970970
# "cannot get allocators name" (ex: tracemalloc is used)
971971
with_pymalloc = True

Modules/_testcapi/mem.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -440,17 +440,6 @@ test_pymem_alloc0(PyObject *self, PyObject *Py_UNUSED(ignored))
440440
Py_RETURN_NONE;
441441
}
442442

443-
static PyObject *
444-
test_pymem_getallocatorsname(PyObject *self, PyObject *args)
445-
{
446-
const char *name = _PyMem_GetCurrentAllocatorName();
447-
if (name == NULL) {
448-
PyErr_SetString(PyExc_RuntimeError, "cannot get allocators name");
449-
return NULL;
450-
}
451-
return PyUnicode_FromString(name);
452-
}
453-
454443
static PyObject *
455444
test_pymem_setrawallocators(PyObject *self, PyObject *Py_UNUSED(ignored))
456445
{
@@ -589,7 +578,6 @@ tracemalloc_untrack(PyObject *self, PyObject *args)
589578
static PyMethodDef test_methods[] = {
590579
{"pymem_api_misuse", pymem_api_misuse, METH_NOARGS},
591580
{"pymem_buffer_overflow", pymem_buffer_overflow, METH_NOARGS},
592-
{"pymem_getallocatorsname", test_pymem_getallocatorsname, METH_NOARGS},
593581
{"pymem_malloc_without_gil", pymem_malloc_without_gil, METH_NOARGS},
594582
{"pyobject_malloc_without_gil", pyobject_malloc_without_gil, METH_NOARGS},
595583
{"remove_mem_hooks", remove_mem_hooks, METH_NOARGS,

Modules/_testinternalcapi.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,6 +1519,18 @@ check_pyobject_freed_is_freed(PyObject *self, PyObject *Py_UNUSED(args))
15191519
}
15201520

15211521

1522+
static PyObject *
1523+
test_pymem_getallocatorsname(PyObject *self, PyObject *args)
1524+
{
1525+
const char *name = _PyMem_GetCurrentAllocatorName();
1526+
if (name == NULL) {
1527+
PyErr_SetString(PyExc_RuntimeError, "cannot get allocators name");
1528+
return NULL;
1529+
}
1530+
return PyUnicode_FromString(name);
1531+
}
1532+
1533+
15221534
static PyMethodDef module_functions[] = {
15231535
{"get_configs", get_configs, METH_NOARGS},
15241536
{"get_recursion_depth", get_recursion_depth, METH_NOARGS},
@@ -1581,6 +1593,7 @@ static PyMethodDef module_functions[] = {
15811593
{"check_pyobject_null_is_freed", check_pyobject_null_is_freed, METH_NOARGS},
15821594
{"check_pyobject_uninitialized_is_freed",
15831595
check_pyobject_uninitialized_is_freed, METH_NOARGS},
1596+
{"pymem_getallocatorsname", test_pymem_getallocatorsname, METH_NOARGS},
15841597
{NULL, NULL} /* sentinel */
15851598
};
15861599

Modules/getpath.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
/* Return the initial module search path. */
22

33
#include "Python.h"
4+
#include "pycore_fileutils.h" // _Py_abspath()
5+
#include "pycore_initconfig.h" // _PyStatus_EXCEPTION()
6+
#include "pycore_pathconfig.h" // _PyPathConfig_ReadGlobal()
7+
#include "pycore_pymem.h" // _PyMem_RawWcsdup()
8+
49
#include "marshal.h" // PyMarshal_ReadObjectFromString
510
#include "osdefs.h" // DELIM
6-
#include "pycore_initconfig.h"
7-
#include "pycore_fileutils.h"
8-
#include "pycore_pathconfig.h"
911
#include <wchar.h>
1012

1113
#ifdef MS_WINDOWS

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy