bpo-36301: Add _Py_GetConfigsAsDict() function (GH-12540)
* Add _Py_GetConfigsAsDict() function to get all configurations as a
dict.
* dump_config() of _testembed.c now dumps preconfig as a separated
key: call _Py_GetConfigsAsDict().
* Make _PyMainInterpreterConfig_AsDict() private.
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index 350ef77..c82ba0c 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -4675,27 +4675,9 @@
static PyObject *
-get_global_config(PyObject *self, PyObject *Py_UNUSED(args))
+get_configs(PyObject *self, PyObject *Py_UNUSED(args))
{
- return _Py_GetGlobalVariablesAsDict();
-}
-
-
-static PyObject *
-get_core_config(PyObject *self, PyObject *Py_UNUSED(args))
-{
- PyInterpreterState *interp = _PyInterpreterState_Get();
- const _PyCoreConfig *config = _PyInterpreterState_GetCoreConfig(interp);
- return _PyCoreConfig_AsDict(config);
-}
-
-
-static PyObject *
-get_main_config(PyObject *self, PyObject *Py_UNUSED(args))
-{
- PyInterpreterState *interp = _PyInterpreterState_Get();
- const _PyMainInterpreterConfig *config = _PyInterpreterState_GetMainConfig(interp);
- return _PyMainInterpreterConfig_AsDict(config);
+ return _Py_GetConfigsAsDict();
}
@@ -4942,9 +4924,7 @@
{"bad_get", (PyCFunction)(void(*)(void))bad_get, METH_FASTCALL},
{"EncodeLocaleEx", encode_locale_ex, METH_VARARGS},
{"DecodeLocaleEx", decode_locale_ex, METH_VARARGS},
- {"get_global_config", get_global_config, METH_NOARGS},
- {"get_core_config", get_core_config, METH_NOARGS},
- {"get_main_config", get_main_config, METH_NOARGS},
+ {"get_configs", get_configs, METH_NOARGS},
#ifdef Py_REF_DEBUG
{"negative_refcount", negative_refcount, METH_NOARGS},
#endif