bpo-36301: _PyCoreConfig_Read() ensures that argv is not empty (GH-12… · python/cpython@6259976 (original) (raw)
2 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -292,7 +292,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase): | ||
292 | 292 | |
293 | 293 | 'pycache_prefix': None, |
294 | 294 | 'program_name': './_testembed', |
295 | -'argv': [], | |
295 | +'argv': [""], | |
296 | 296 | 'program': None, |
297 | 297 | |
298 | 298 | 'xoptions': [], |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1464,6 +1464,13 @@ _PyCoreConfig_Read(_PyCoreConfig *config, const _PyPreConfig *preconfig) | ||
1464 | 1464 | return err; |
1465 | 1465 | } |
1466 | 1466 | |
1467 | +if (config->argv.length < 1) { | |
1468 | +/* Ensure at least one (empty) argument is seen */ | |
1469 | +if (_PyWstrList_Append(&config->argv, L"") < 0) { | |
1470 | +return _Py_INIT_NO_MEMORY(); | |
1471 | + } | |
1472 | + } | |
1473 | + | |
1467 | 1474 | assert(config->preconfig.use_environment >= 0); |
1468 | 1475 | assert(config->filesystem_encoding != NULL); |
1469 | 1476 | assert(config->filesystem_errors != NULL); |