[Python-checkins] bpo-35233: Fix _PyMainInterpreterConfig_Copy() (GH-10537)

Victor Stinner webhook-mailer at python.org
Tue Nov 13 20:45:39 EST 2018


https://github.com/python/cpython/commit/88cbea4c6ff4987ce31f4fe6f73c2d04a3d37829
commit: 88cbea4c6ff4987ce31f4fe6f73c2d04a3d37829
branch: 3.7
author: Victor Stinner <vstinner at redhat.com>
committer: GitHub <noreply at github.com>
date: 2018-11-14T02:45:25+01:00
summary:

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

Fix _PyMainInterpreterConfig_Copy(): copy 'install_signal_handlers'
attribute

files:
M Lib/test/test_embed.py
M Modules/main.c

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 @@ def check_config(self, testname, expected, expected_global):
             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;
 }
 



More information about the Python-checkins mailing list