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.
diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py
index fe47289..174892a 100644
--- a/Lib/test/test_embed.py
+++ b/Lib/test/test_embed.py
@@ -365,7 +365,7 @@
'program_name': GET_DEFAULT_CONFIG,
'parse_argv': 0,
'argv': [""],
- '_orig_argv': [],
+ 'orig_argv': [],
'xoptions': [],
'warnoptions': [],
@@ -739,11 +739,11 @@
'pycache_prefix': 'conf_pycache_prefix',
'program_name': './conf_program_name',
'argv': ['-c', 'arg2'],
- '_orig_argv': ['python3',
- '-W', 'cmdline_warnoption',
- '-X', 'cmdline_xoption',
- '-c', 'pass',
- 'arg2'],
+ 'orig_argv': ['python3',
+ '-W', 'cmdline_warnoption',
+ '-X', 'cmdline_xoption',
+ '-c', 'pass',
+ 'arg2'],
'parse_argv': 1,
'xoptions': [
'config_xoption1=3',
@@ -874,7 +874,7 @@
}
config = {
'argv': ['script.py'],
- '_orig_argv': ['python3', '-X', 'dev', 'script.py'],
+ 'orig_argv': ['python3', '-X', 'dev', 'script.py'],
'run_filename': os.path.abspath('script.py'),
'dev_mode': 1,
'faulthandler': 1,
@@ -896,7 +896,7 @@
"script.py"]
config = {
'argv': argv,
- '_orig_argv': argv,
+ 'orig_argv': argv,
'isolated': 0,
}
self.check_all_configs("test_preinit_dont_parse_argv", config, preconfig,
@@ -975,9 +975,9 @@
'ignore:::sysadd_warnoption',
'ignore:::config_warnoption',
],
- '_orig_argv': ['python3',
- '-W', 'ignore:::cmdline_warnoption',
- '-X', 'cmdline_xoption'],
+ 'orig_argv': ['python3',
+ '-W', 'ignore:::cmdline_warnoption',
+ '-X', 'cmdline_xoption'],
}
self.check_all_configs("test_init_sys_add", config, api=API_PYTHON)
@@ -986,7 +986,7 @@
'print(json.dumps(_testinternalcapi.get_configs()))')
config = {
'argv': ['-c', 'arg2'],
- '_orig_argv': ['python3', '-c', code, 'arg2'],
+ 'orig_argv': ['python3', '-c', code, 'arg2'],
'program_name': './python3',
'run_command': code + '\n',
'parse_argv': 1,
@@ -998,9 +998,9 @@
'print(json.dumps(_testinternalcapi.get_configs()))')
config = {
'argv': ['-c', 'arg2'],
- '_orig_argv': ['python3',
- '-c', code,
- 'arg2'],
+ 'orig_argv': ['python3',
+ '-c', code,
+ 'arg2'],
'program_name': './python3',
'run_command': code + '\n',
'parse_argv': 1,
@@ -1014,7 +1014,7 @@
config = {
'parse_argv': 1,
'argv': ['-c', 'arg1', '-v', 'arg3'],
- '_orig_argv': ['./argv0', '-E', '-c', 'pass', 'arg1', '-v', 'arg3'],
+ 'orig_argv': ['./argv0', '-E', '-c', 'pass', 'arg1', '-v', 'arg3'],
'program_name': './argv0',
'run_command': 'pass\n',
'use_environment': 0,
@@ -1028,7 +1028,7 @@
config = {
'parse_argv': 0,
'argv': ['./argv0', '-E', '-c', 'pass', 'arg1', '-v', 'arg3'],
- '_orig_argv': ['./argv0', '-E', '-c', 'pass', 'arg1', '-v', 'arg3'],
+ 'orig_argv': ['./argv0', '-E', '-c', 'pass', 'arg1', '-v', 'arg3'],
'program_name': './argv0',
}
self.check_all_configs("test_init_dont_parse_argv", config, pre_config,
@@ -1316,9 +1316,9 @@
'faulthandler': 1,
'bytes_warning': 1,
'warnoptions': warnoptions,
- '_orig_argv': ['python3',
- '-Wignore:::cmdline1',
- '-Wignore:::cmdline2'],
+ 'orig_argv': ['python3',
+ '-Wignore:::cmdline1',
+ '-Wignore:::cmdline2'],
}
self.check_all_configs("test_init_warnoptions", config, preconfig,
api=API_PYTHON)