Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
bpo-34170: _PyCoreConfig_Read() defaults to argc=0
Add unit tests for argc and argv of _PyCoreConfig.
  • Loading branch information
vstinner committed Aug 1, 2018
commit 509ffd9ba4f90aefd5709b4e8553bd133797edb6
2 changes: 2 additions & 0 deletions Lib/test/test_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):

'pycache_prefix': '(null)',
'program_name': './_testembed',
'argc': 0,
'argv': '[]',
'program': '(null)',

'isolated': 0,
Expand Down
3 changes: 3 additions & 0 deletions Modules/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2286,6 +2286,9 @@ _PyCoreConfig_Read(_PyCoreConfig *config)
if (config->_frozen < 0) {
config->_frozen = 0;
}
if (config->argc < 0) {
config->argc = 0;
}

return _Py_INIT_OK();
}
Expand Down
12 changes: 11 additions & 1 deletion Programs/_testembed.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down