Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Commit 81f6b03

Browse files
authored
bpo-38304: Fix PyConfig usage in python_uwp.cpp (pythonGH-16488)
* Set PyPreConfig.struct_size and PyConfig.struct_size as required by the API. * PyPreConfig_InitPythonConfig() can now fail: check PyStatus result.
1 parent bfca56b commit 81f6b03

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

PC/python_uwp.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,10 @@ wmain(int argc, wchar_t **argv)
167167
PyStatus status;
168168

169169
PyPreConfig preconfig;
170+
preconfig.struct_size = sizeof(PyPreConfig);
171+
170172
PyConfig config;
173+
config.struct_size = sizeof(PyConfig);
171174

172175
const wchar_t *moduleName = NULL;
173176
const wchar_t *p = wcsrchr(argv[0], L'\\');
@@ -186,7 +189,10 @@ wmain(int argc, wchar_t **argv)
186189
}
187190
}
188191

189-
PyPreConfig_InitPythonConfig(&preconfig);
192+
status = PyPreConfig_InitPythonConfig(&preconfig);
193+
if (PyStatus_Exception(status)) {
194+
goto fail_without_config;
195+
}
190196
if (!moduleName) {
191197
status = Py_PreInitializeFromArgs(&preconfig, argc, argv);
192198
if (PyStatus_Exception(status)) {

0 commit comments

Comments
 (0)