]> granicus.if.org Git - python/commitdiff
bpo-34170: _PyCoreConfig_Read() defaults to argc=0 (GH-8595)
authorVictor Stinner <vstinner@redhat.com>
Wed, 1 Aug 2018 01:07:18 +0000 (03:07 +0200)
committerGitHub <noreply@github.com>
Wed, 1 Aug 2018 01:07:18 +0000 (03:07 +0200)
Add unit tests for argc and argv of _PyCoreConfig.

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

index 79622f15945f68f5940a8ba33a0ba07017f93340..25593bdf4208665d91805e96670bbca96b777140 100644 (file)
@@ -272,6 +272,8 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
 
         'pycache_prefix': '(null)',
         'program_name': './_testembed',
+        'argc': 0,
+        'argv': '[]',
         'program': '(null)',
 
         'isolated': 0,
index aef821fe93c3a5d9066a4c34c9f7d981f37dae76..664a70ad5ebb5ab4dfc75464ea3408f1aa6ad8a5 100644 (file)
@@ -2294,6 +2294,9 @@ _PyCoreConfig_Read(_PyCoreConfig *config)
     if (config->_frozen < 0) {
         config->_frozen = 0;
     }
+    if (config->argc < 0) {
+        config->argc = 0;
+    }
 
     return _Py_INIT_OK();
 }
index 1cdc4c3648f916f47efe89884d3a67f1345d20e1..1c72580b9c67c79a4a7a67d3ad37dbf67d953102 100644 (file)
@@ -335,7 +335,17 @@ dump_config(void)
     printf("pycache_prefix = %ls\n", config->pycache_prefix);
     printf("program_name = %ls\n", config->program_name);
     ASSERT_STR_EQUAL(config->program_name, Py_GetProgramName());
-    /* FIXME: test argc/argv */
+
+    printf("argc = %i\n", config->argc);
+    printf("argv = [");
+    for (int i=0; i < config->argc; i++) {
+        if (i) {
+            printf(", ");
+        }
+        printf("\"%ls\"", config->argv[i]);
+    }
+    printf("]\n");
+
     printf("program = %ls\n", config->program);
     /* FIXME: test xoptions */
     /* FIXME: test warnoptions */