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.
This commit is contained in:
Victor Stinner 2019-03-25 23:19:57 +01:00 committed by GitHub
parent 91759d9801
commit 1075d1684a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 179 additions and 134 deletions

View file

@ -598,18 +598,15 @@ def collect_get_config(info_add):
# Dump global configuration variables, _PyCoreConfig
# and _PyMainInterpreterConfig
try:
from _testcapi import get_global_config, get_core_config, get_main_config
from _testcapi import get_configs
except ImportError:
return
for prefix, get_config_func in (
('global_config', get_global_config),
('core_config', get_core_config),
('main_config', get_main_config),
):
config = get_config_func()
all_configs = get_configs()
for config_type in sorted(all_configs):
config = all_configs[config_type]
for key in sorted(config):
info_add('%s[%s]' % (prefix, key), repr(config[key]))
info_add('%s[%s]' % (config_type, key), repr(config[key]))
def collect_subprocess(info_add):