From: Victor Stinner Date: Wed, 14 Nov 2018 01:45:25 +0000 (+0100) Subject: bpo-35233: Fix _PyMainInterpreterConfig_Copy() (GH-10537) X-Git-Tag: v3.7.2rc1~139 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=88cbea4c6ff4987ce31f4fe6f73c2d04a3d37829;p=thirdparty%2FPython%2Fcpython.git bpo-35233: Fix _PyMainInterpreterConfig_Copy() (GH-10537) Fix _PyMainInterpreterConfig_Copy(): copy 'install_signal_handlers' attribute --- diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py index 62a20abf0377..856116fdbb17 100644 --- a/Lib/test/test_embed.py +++ b/Lib/test/test_embed.py @@ -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'], diff --git a/Modules/main.c b/Modules/main.c index ab7ac86bad91..c0a9c262dfb5 100644 --- a/Modules/main.c +++ b/Modules/main.c @@ -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; }