diff options
author | Victor Stinner <vstinner@redhat.com> | 2019-03-25 22:19:57 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-25 22:19:57 (GMT) |
commit | 1075d1684ab84dc7c28d93cfb46e95e70d3b6d3b (patch) | |
tree | 7a0543a13a28f88318d16f8900111ea10198a4a3 /Python/preconfig.c | |
parent | 91759d98015e1d6d5e1367cff60592ab548e7806 (diff) | |
download | cpython-1075d1684ab84dc7c28d93cfb46e95e70d3b6d3b.zip cpython-1075d1684ab84dc7c28d93cfb46e95e70d3b6d3b.tar.gz cpython-1075d1684ab84dc7c28d93cfb46e95e70d3b6d3b.tar.bz2 |
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.
Diffstat (limited to 'Python/preconfig.c')
-rw-r--r-- | Python/preconfig.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/Python/preconfig.c b/Python/preconfig.c index ac87a7a..c65ee28 100644 --- a/Python/preconfig.c +++ b/Python/preconfig.c @@ -574,9 +574,16 @@ _PyPreCmdline_SetPreConfig(const _PyPreCmdline *cmdline, _PyPreConfig *config) } -int -_PyPreConfig_AsDict(const _PyPreConfig *config, PyObject *dict) +PyObject* +_PyPreConfig_AsDict(const _PyPreConfig *config) { + PyObject *dict; + + dict = PyDict_New(); + if (dict == NULL) { + return NULL; + } + #define SET_ITEM(KEY, EXPR) \ do { \ PyObject *obj = (EXPR); \ @@ -608,10 +615,11 @@ _PyPreConfig_AsDict(const _PyPreConfig *config, PyObject *dict) #endif SET_ITEM_INT(dev_mode); SET_ITEM_STR(allocator); - return 0; + return dict; fail: - return -1; + Py_DECREF(dict); + return NULL; #undef FROM_STRING #undef SET_ITEM |