mirror of
https://github.com/python/cpython.git
synced 2025-07-16 07:45:20 +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
|
@ -365,7 +365,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
|||
'program_name': GET_DEFAULT_CONFIG,
|
||||
'parse_argv': 0,
|
||||
'argv': [""],
|
||||
'_orig_argv': [],
|
||||
'orig_argv': [],
|
||||
|
||||
'xoptions': [],
|
||||
'warnoptions': [],
|
||||
|
@ -739,11 +739,11 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
|||
'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 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
|||
}
|
||||
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 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
|||
"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 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
|||
'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 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
|||
'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 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
|||
'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 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
|||
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 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
|||
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 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
|||
'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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue