summaryrefslogtreecommitdiff
path: root/Python/preconfig.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/preconfig.c')
-rw-r--r--Python/preconfig.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/Python/preconfig.c b/Python/preconfig.c
index ac87a7a3c7..c65ee28f73 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