mirror of
https://github.com/python/cpython.git
synced 2025-08-30 13:38:43 +00:00
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.
This commit is contained in:
parent
2fb5f038f2
commit
dd8a93e23b
9 changed files with 104 additions and 35 deletions
|
@ -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();
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue