bpo-35233: Fix _PyMainInterpreterConfig_Copy() (GH-10537)

Fix _PyMainInterpreterConfig_Copy(): copy 'install_signal_handlers'
attribute
This commit is contained in:
Victor Stinner 2018-11-14 02:45:25 +01:00 committed by GitHub
parent 35c28d562e
commit 88cbea4c6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 14 deletions

View File

@ -267,7 +267,6 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
)
# FIXME: untested main configuration variables
UNTESTED_MAIN_CONFIG = (
'install_signal_handlers',
'module_search_path',
)
DEFAULT_GLOBAL_CONFIG = {
@ -363,6 +362,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
del main_config[key]
expected_main = {
'install_signal_handlers': core_config['install_signal_handlers'],
'argv': [],
'prefix': sys.prefix,
'executable': core_config['executable'],

View File

@ -2652,26 +2652,29 @@ _PyMainInterpreterConfig_Copy(_PyMainInterpreterConfig *config,
{
_PyMainInterpreterConfig_Clear(config);
#define COPY_ATTR(ATTR) \
#define COPY_ATTR(ATTR) config->ATTR = config2->ATTR
#define COPY_OBJ_ATTR(OBJ_ATTR) \
do { \
if (config2->ATTR != NULL) { \
config->ATTR = config_copy_attr(config2->ATTR); \
if (config->ATTR == NULL) { \
if (config2->OBJ_ATTR != NULL) { \
config->OBJ_ATTR = config_copy_attr(config2->OBJ_ATTR); \
if (config->OBJ_ATTR == NULL) { \
return -1; \
} \
} \
} while (0)
COPY_ATTR(argv);
COPY_ATTR(executable);
COPY_ATTR(prefix);
COPY_ATTR(base_prefix);
COPY_ATTR(exec_prefix);
COPY_ATTR(base_exec_prefix);
COPY_ATTR(warnoptions);
COPY_ATTR(xoptions);
COPY_ATTR(module_search_path);
COPY_ATTR(install_signal_handlers);
COPY_OBJ_ATTR(argv);
COPY_OBJ_ATTR(executable);
COPY_OBJ_ATTR(prefix);
COPY_OBJ_ATTR(base_prefix);
COPY_OBJ_ATTR(exec_prefix);
COPY_OBJ_ATTR(base_exec_prefix);
COPY_OBJ_ATTR(warnoptions);
COPY_OBJ_ATTR(xoptions);
COPY_OBJ_ATTR(module_search_path);
#undef COPY_ATTR
#undef COPY_OBJ_ATTR
return 0;
}