]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-35233: Fix _PyMainInterpreterConfig_Copy() (GH-10537)
authorVictor Stinner <vstinner@redhat.com>
Wed, 14 Nov 2018 01:45:25 +0000 (02:45 +0100)
committerGitHub <noreply@github.com>
Wed, 14 Nov 2018 01:45:25 +0000 (02:45 +0100)
Fix _PyMainInterpreterConfig_Copy(): copy 'install_signal_handlers'
attribute

Lib/test/test_embed.py
Modules/main.c

index 62a20abf03774072c8a4d234327492a03574b0a5..856116fdbb1790cd7f4bada0c210585140096e44 100644 (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'],
index ab7ac86bad9116f045d3c118929fd6b9cf6e3865..c0a9c262dfb5e506281196d66c99cafc7264d94d 100644 (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;
 }