diff options
author | Victor Stinner <vstinner@python.org> | 2020-06-30 00:49:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-30 00:49:03 +0200 |
commit | dd8a93e23b5c4f9290e1cea6183d97eb9b5e61c0 (patch) | |
tree | e313d1898cff674146bfb1fef17f082f56628ed4 /Python | |
parent | 2fb5f038f2a2e91a7293d62dfd5601e6eb500c55 (diff) | |
download | cpython-git-dd8a93e23b5c4f9290e1cea6183d97eb9b5e61c0.tar.gz |
bpo-23427: Add sys.orig_argv attribute (GH-20729)
Add sys.orig_argv attribute: the list of the original command line
arguments passed to the Python executable.
Rename also PyConfig._orig_argv to PyConfig.orig_argv and
document it.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/initconfig.c | 16 | ||||
-rw-r--r-- | Python/sysmodule.c | 1 |
2 files changed, 9 insertions, 8 deletions
diff --git a/Python/initconfig.c b/Python/initconfig.c index 9616945450..86285c77e2 100644 --- a/Python/initconfig.c +++ b/Python/initconfig.c @@ -601,7 +601,7 @@ PyConfig_Clear(PyConfig *config) CLEAR(config->run_filename); CLEAR(config->check_hash_pycs_mode); - _PyWideStringList_Clear(&config->_orig_argv); + _PyWideStringList_Clear(&config->orig_argv); #undef CLEAR } @@ -856,7 +856,7 @@ _PyConfig_Copy(PyConfig *config, const PyConfig *config2) COPY_ATTR(pathconfig_warnings); COPY_ATTR(_init_main); COPY_ATTR(_isolated_interpreter); - COPY_WSTRLIST(_orig_argv); + COPY_WSTRLIST(orig_argv); #undef COPY_ATTR #undef COPY_WSTR_ATTR @@ -957,7 +957,7 @@ config_as_dict(const PyConfig *config) SET_ITEM_INT(pathconfig_warnings); SET_ITEM_INT(_init_main); SET_ITEM_INT(_isolated_interpreter); - SET_ITEM_WSTRLIST(_orig_argv); + SET_ITEM_WSTRLIST(orig_argv); return dict; @@ -1864,8 +1864,8 @@ _PyConfig_Write(const PyConfig *config, _PyRuntimeState *runtime) preconfig->use_environment = config->use_environment; preconfig->dev_mode = config->dev_mode; - if (_Py_SetArgcArgv(config->_orig_argv.length, - config->_orig_argv.items) < 0) + if (_Py_SetArgcArgv(config->orig_argv.length, + config->orig_argv.items) < 0) { return _PyStatus_NO_MEMORY(); } @@ -2501,11 +2501,11 @@ PyConfig_Read(PyConfig *config) config_get_global_vars(config); - if (config->_orig_argv.length == 0 + if (config->orig_argv.length == 0 && !(config->argv.length == 1 && wcscmp(config->argv.items[0], L"") == 0)) { - if (_PyWideStringList_Copy(&config->_orig_argv, &config->argv) < 0) { + if (_PyWideStringList_Copy(&config->orig_argv, &config->argv) < 0) { return _PyStatus_NO_MEMORY(); } } @@ -2589,7 +2589,7 @@ PyConfig_Read(PyConfig *config) assert(config->check_hash_pycs_mode != NULL); assert(config->_install_importlib >= 0); assert(config->pathconfig_warnings >= 0); - assert(_PyWideStringList_CheckConsistency(&config->_orig_argv)); + assert(_PyWideStringList_CheckConsistency(&config->orig_argv)); status = _PyStatus_OK(); diff --git a/Python/sysmodule.c b/Python/sysmodule.c index f3b5a6afdf..9fcdb5dbc4 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -2931,6 +2931,7 @@ _PySys_InitMain(PyThreadState *tstate) } COPY_LIST("argv", config->argv); + COPY_LIST("orig_argv", config->orig_argv); COPY_LIST("warnoptions", config->warnoptions); PyObject *xoptions = sys_create_xoptions_dict(config); |