Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8ceb6cb

Browse filesBrowse files
authored
gh-129033: Remove _PyInterpreterState_SetConfig() function (#129048)
Remove _PyInterpreterState_GetConfigCopy() and _PyInterpreterState_SetConfig() private functions. PEP 741 "Python Configuration C API" added a better public C API: PyConfig_Get() and PyConfig_Set().
1 parent 573c181 commit 8ceb6cb
Copy full SHA for 8ceb6cb

File tree

Expand file treeCollapse file tree

11 files changed

+22
-500
lines changed
Filter options
Expand file treeCollapse file tree

11 files changed

+22
-500
lines changed

‎Include/internal/pycore_interp.h

Copy file name to clipboardExpand all lines: Include/internal/pycore_interp.h
-37Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -341,43 +341,6 @@ extern void _PyInterpreterState_SetWhence(
341341

342342
extern const PyConfig* _PyInterpreterState_GetConfig(PyInterpreterState *interp);
343343

344-
// Get a copy of the current interpreter configuration.
345-
//
346-
// Return 0 on success. Raise an exception and return -1 on error.
347-
//
348-
// The caller must initialize 'config', using PyConfig_InitPythonConfig()
349-
// for example.
350-
//
351-
// Python must be preinitialized to call this method.
352-
// The caller must hold the GIL.
353-
//
354-
// Once done with the configuration, PyConfig_Clear() must be called to clear
355-
// it.
356-
//
357-
// Export for '_testinternalcapi' shared extension.
358-
PyAPI_FUNC(int) _PyInterpreterState_GetConfigCopy(
359-
struct PyConfig *config);
360-
361-
// Set the configuration of the current interpreter.
362-
//
363-
// This function should be called during or just after the Python
364-
// initialization.
365-
//
366-
// Update the sys module with the new configuration. If the sys module was
367-
// modified directly after the Python initialization, these changes are lost.
368-
//
369-
// Some configuration like faulthandler or warnoptions can be updated in the
370-
// configuration, but don't reconfigure Python (don't enable/disable
371-
// faulthandler and don't reconfigure warnings filters).
372-
//
373-
// Return 0 on success. Raise an exception and return -1 on error.
374-
//
375-
// The configuration should come from _PyInterpreterState_GetConfigCopy().
376-
//
377-
// Export for '_testinternalcapi' shared extension.
378-
PyAPI_FUNC(int) _PyInterpreterState_SetConfig(
379-
const struct PyConfig *config);
380-
381344

382345
/*
383346
Runtime Feature Flags

‎Lib/test/_test_embed_set_config.py

Copy file name to clipboardExpand all lines: Lib/test/_test_embed_set_config.py
-291Lines changed: 0 additions & 291 deletions
This file was deleted.

‎Lib/test/support/__init__.py

Copy file name to clipboardExpand all lines: Lib/test/support/__init__.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,10 +505,10 @@ def requires_lzma(reason='requires lzma'):
505505

506506
def has_no_debug_ranges():
507507
try:
508-
import _testinternalcapi
508+
import _testcapi
509509
except ImportError:
510510
raise unittest.SkipTest("_testinternalcapi required")
511-
config = _testinternalcapi.get_config()
511+
return not _testcapi.config_get('code_debug_ranges')
512512
return not bool(config['code_debug_ranges'])
513513

514514
def requires_debug_ranges(reason='requires co_positions / debug_ranges'):

‎Lib/test/test_capi/test_misc.py

Copy file name to clipboardExpand all lines: Lib/test/test_capi/test_misc.py
+8-9Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2141,28 +2141,27 @@ async def foo(arg): return await arg # Py 3.5
21412141
self.assertEqual(ret, 0)
21422142
self.assertEqual(pickle.load(f), {'a': '123x', 'b': '123'})
21432143

2144+
# _testcapi cannot be imported in a subinterpreter on a Free Threaded build
2145+
@support.requires_gil_enabled()
21442146
def test_py_config_isoloated_per_interpreter(self):
21452147
# A config change in one interpreter must not leak to out to others.
21462148
#
21472149
# This test could verify ANY config value, it just happens to have been
21482150
# written around the time of int_max_str_digits. Refactoring is okay.
21492151
code = """if 1:
2150-
import sys, _testinternalcapi
2152+
import sys, _testcapi
21512153
21522154
# Any config value would do, this happens to be the one being
21532155
# double checked at the time this test was written.
2154-
config = _testinternalcapi.get_config()
2155-
config['int_max_str_digits'] = 55555
2156-
config['parse_argv'] = 0
2157-
_testinternalcapi.set_config(config)
2158-
sub_value = _testinternalcapi.get_config()['int_max_str_digits']
2156+
_testcapi.config_set('int_max_str_digits', 55555)
2157+
sub_value = _testcapi.config_get('int_max_str_digits')
21592158
assert sub_value == 55555, sub_value
21602159
"""
2161-
before_config = _testinternalcapi.get_config()
2162-
assert before_config['int_max_str_digits'] != 55555
2160+
before_config = _testcapi.config_get('int_max_str_digits')
2161+
assert before_config != 55555
21632162
self.assertEqual(support.run_in_subinterp(code), 0,
21642163
'subinterp code failure, check stderr.')
2165-
after_config = _testinternalcapi.get_config()
2164+
after_config = _testcapi.config_get('int_max_str_digits')
21662165
self.assertIsNot(
21672166
before_config, after_config,
21682167
"Expected get_config() to return a new dict on each call")

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.