mirror of
https://github.com/AdaCore/cpython.git
synced 2026-02-12 12:57:15 -08:00
bpo-36763: Use PyConfig_Clear() (GH-14445)
Stop using "static PyConfig", PyConfig must now always use dynamically allocated strings: use PyConfig_SetString(), PyConfig_SetArgv() and PyConfig_Clear().
This commit is contained in:
@@ -695,10 +695,19 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
||||
|
||||
'pycache_prefix': 'conf_pycache_prefix',
|
||||
'program_name': './conf_program_name',
|
||||
'argv': ['-c', 'arg2'],
|
||||
'argv': ['-c', 'arg2', ],
|
||||
'parse_argv': 1,
|
||||
'xoptions': ['xoption1=3', 'xoption2=', 'xoption3'],
|
||||
'warnoptions': ['error::ResourceWarning', 'default::BytesWarning'],
|
||||
'xoptions': [
|
||||
'config_xoption1=3',
|
||||
'config_xoption2=',
|
||||
'config_xoption3',
|
||||
'cmdline_xoption',
|
||||
],
|
||||
'warnoptions': [
|
||||
'config_warnoption',
|
||||
'cmdline_warnoption',
|
||||
'default::BytesWarning',
|
||||
],
|
||||
'run_command': 'pass\n',
|
||||
|
||||
'site_import': 0,
|
||||
|
||||
@@ -62,7 +62,7 @@ pymain_init(const _PyArgv *args)
|
||||
PyConfig config;
|
||||
status = PyConfig_InitPythonConfig(&config);
|
||||
if (_PyStatus_EXCEPTION(status)) {
|
||||
return status;
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* pass NULL as the config: config is read from command line arguments,
|
||||
@@ -74,14 +74,18 @@ pymain_init(const _PyArgv *args)
|
||||
status = PyConfig_SetArgv(&config, args->argc, args->wchar_argv);
|
||||
}
|
||||
if (_PyStatus_EXCEPTION(status)) {
|
||||
return status;
|
||||
goto done;
|
||||
}
|
||||
|
||||
status = Py_InitializeFromConfig(&config);
|
||||
if (_PyStatus_EXCEPTION(status)) {
|
||||
return status;
|
||||
goto done;
|
||||
}
|
||||
return _PyStatus_OK();
|
||||
status = _PyStatus_OK();
|
||||
|
||||
done:
|
||||
PyConfig_Clear(&config);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ main(int argc, char *argv[])
|
||||
config.site_import = 0;
|
||||
|
||||
status = PyConfig_SetString(&config, &config.program_name,
|
||||
L"./_freeze_importlib");
|
||||
L"./_freeze_importlib");
|
||||
if (PyStatus_Exception(status)) {
|
||||
PyConfig_Clear(&config);
|
||||
Py_ExitStatusException(status);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user