mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
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().
This commit is contained in:
parent
573c181502
commit
8ceb6cb117
11 changed files with 22 additions and 500 deletions
|
|
@ -25,7 +25,6 @@
|
|||
#include "pycore_hashtable.h" // _Py_hashtable_new()
|
||||
#include "pycore_initconfig.h" // _Py_GetConfigsAsDict()
|
||||
#include "pycore_instruction_sequence.h" // _PyInstructionSequence_New()
|
||||
#include "pycore_interp.h" // _PyInterpreterState_GetConfigCopy()
|
||||
#include "pycore_long.h" // _PyLong_Sign()
|
||||
#include "pycore_object.h" // _PyObject_IsFreed()
|
||||
#include "pycore_optimizer.h" // _Py_UopsSymbol, etc.
|
||||
|
|
@ -318,41 +317,6 @@ test_hashtable(PyObject *self, PyObject *Py_UNUSED(args))
|
|||
}
|
||||
|
||||
|
||||
static PyObject *
|
||||
test_get_config(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(args))
|
||||
{
|
||||
PyConfig config;
|
||||
PyConfig_InitIsolatedConfig(&config);
|
||||
if (_PyInterpreterState_GetConfigCopy(&config) < 0) {
|
||||
PyConfig_Clear(&config);
|
||||
return NULL;
|
||||
}
|
||||
PyObject *dict = _PyConfig_AsDict(&config);
|
||||
PyConfig_Clear(&config);
|
||||
return dict;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *
|
||||
test_set_config(PyObject *Py_UNUSED(self), PyObject *dict)
|
||||
{
|
||||
PyConfig config;
|
||||
PyConfig_InitIsolatedConfig(&config);
|
||||
if (_PyConfig_FromDict(&config, dict) < 0) {
|
||||
goto error;
|
||||
}
|
||||
if (_PyInterpreterState_SetConfig(&config) < 0) {
|
||||
goto error;
|
||||
}
|
||||
PyConfig_Clear(&config);
|
||||
Py_RETURN_NONE;
|
||||
|
||||
error:
|
||||
PyConfig_Clear(&config);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *
|
||||
test_reset_path_config(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(arg))
|
||||
{
|
||||
|
|
@ -2062,8 +2026,6 @@ static PyMethodDef module_functions[] = {
|
|||
{"test_popcount", test_popcount, METH_NOARGS},
|
||||
{"test_bit_length", test_bit_length, METH_NOARGS},
|
||||
{"test_hashtable", test_hashtable, METH_NOARGS},
|
||||
{"get_config", test_get_config, METH_NOARGS},
|
||||
{"set_config", test_set_config, METH_O},
|
||||
{"reset_path_config", test_reset_path_config, METH_NOARGS},
|
||||
{"test_edit_cost", test_edit_cost, METH_NOARGS},
|
||||
{"test_bytes_find", test_bytes_find, METH_NOARGS},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue