]> granicus.if.org Git - python/commitdiff
bpo-38304: Fix PyConfig usage in python_uwp.cpp (GH-16487)
authorVictor Stinner <vstinner@redhat.com>
Mon, 30 Sep 2019 10:52:29 +0000 (12:52 +0200)
committerGitHub <noreply@github.com>
Mon, 30 Sep 2019 10:52:29 +0000 (12:52 +0200)
* Set PyPreConfig.struct_size and PyConfig.struct_size as required by
  the API.
* PyPreConfig_InitPythonConfig() can now fail: check PyStatus result.

PC/python_uwp.cpp

index 06c1dd35365554b38c859bcf004985c6a268bf6f..2656d188c250a836a66df3595c06e3f606ec1a84 100644 (file)
@@ -167,7 +167,10 @@ wmain(int argc, wchar_t **argv)
     PyStatus status;
 
     PyPreConfig preconfig;
+    preconfig.struct_size = sizeof(PyPreConfig);
+
     PyConfig config;
+    config.struct_size = sizeof(PyConfig);
 
     const wchar_t *moduleName = NULL;
     const wchar_t *p = wcsrchr(argv[0], L'\\');
@@ -186,7 +189,10 @@ wmain(int argc, wchar_t **argv)
         }
     }
 
-    PyPreConfig_InitPythonConfig(&preconfig);
+    status = PyPreConfig_InitPythonConfig(&preconfig);
+    if (PyStatus_Exception(status)) {
+        goto fail_without_config;
+    }
     if (!moduleName) {
         status = Py_PreInitializeFromArgs(&preconfig, argc, argv);
         if (PyStatus_Exception(status)) {