mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
bpo-40910: Export Py_GetArgcArgv() function (GH-20721)
Export explicitly the Py_GetArgcArgv() function to the C API and document the function. Previously, it was exported implicitly which no longer works since Python is built with -fvisibility=hidden. * Add PyConfig._orig_argv member. * Py_InitializeFromConfig() no longer calls _PyConfig_Write() twice. * PyConfig_Read() no longer initializes Py_GetArgcArgv(): it is now _PyConfig_Write() responsibility. * _PyConfig_Write() result type becomes PyStatus instead of void. * Write an unit test on Py_GetArgcArgv().
This commit is contained in:
parent
8f023a2f66
commit
e81f6e687d
10 changed files with 131 additions and 22 deletions
|
@ -366,6 +366,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
|||
'program_name': GET_DEFAULT_CONFIG,
|
||||
'parse_argv': 0,
|
||||
'argv': [""],
|
||||
'_orig_argv': [],
|
||||
|
||||
'xoptions': [],
|
||||
'warnoptions': [],
|
||||
|
@ -739,7 +740,12 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
|||
|
||||
'pycache_prefix': 'conf_pycache_prefix',
|
||||
'program_name': './conf_program_name',
|
||||
'argv': ['-c', 'arg2', ],
|
||||
'argv': ['-c', 'arg2'],
|
||||
'_orig_argv': ['python3',
|
||||
'-W', 'cmdline_warnoption',
|
||||
'-X', 'cmdline_xoption',
|
||||
'-c', 'pass',
|
||||
'arg2'],
|
||||
'parse_argv': 1,
|
||||
'xoptions': [
|
||||
'config_xoption1=3',
|
||||
|
@ -872,6 +878,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
|||
}
|
||||
config = {
|
||||
'argv': ['script.py'],
|
||||
'_orig_argv': ['python3', '-X', 'dev', 'script.py'],
|
||||
'run_filename': os.path.abspath('script.py'),
|
||||
'dev_mode': 1,
|
||||
'faulthandler': 1,
|
||||
|
@ -886,9 +893,14 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
|||
preconfig = {
|
||||
'isolated': 0,
|
||||
}
|
||||
argv = ["python3",
|
||||
"-E", "-I",
|
||||
"-X", "dev",
|
||||
"-X", "utf8",
|
||||
"script.py"]
|
||||
config = {
|
||||
'argv': ["python3", "-E", "-I",
|
||||
"-X", "dev", "-X", "utf8", "script.py"],
|
||||
'argv': argv,
|
||||
'_orig_argv': argv,
|
||||
'isolated': 0,
|
||||
}
|
||||
self.check_all_configs("test_preinit_dont_parse_argv", config, preconfig,
|
||||
|
@ -967,6 +979,9 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
|||
'ignore:::sysadd_warnoption',
|
||||
'ignore:::config_warnoption',
|
||||
],
|
||||
'_orig_argv': ['python3',
|
||||
'-W', 'ignore:::cmdline_warnoption',
|
||||
'-X', 'cmdline_xoption'],
|
||||
}
|
||||
self.check_all_configs("test_init_sys_add", config, api=API_PYTHON)
|
||||
|
||||
|
@ -975,6 +990,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
|||
'print(json.dumps(_testinternalcapi.get_configs()))')
|
||||
config = {
|
||||
'argv': ['-c', 'arg2'],
|
||||
'_orig_argv': ['python3', '-c', code, 'arg2'],
|
||||
'program_name': './python3',
|
||||
'run_command': code + '\n',
|
||||
'parse_argv': 1,
|
||||
|
@ -986,6 +1002,9 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
|||
'print(json.dumps(_testinternalcapi.get_configs()))')
|
||||
config = {
|
||||
'argv': ['-c', 'arg2'],
|
||||
'_orig_argv': ['python3',
|
||||
'-c', code,
|
||||
'arg2'],
|
||||
'program_name': './python3',
|
||||
'run_command': code + '\n',
|
||||
'parse_argv': 1,
|
||||
|
@ -999,6 +1018,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
|||
config = {
|
||||
'parse_argv': 1,
|
||||
'argv': ['-c', 'arg1', '-v', 'arg3'],
|
||||
'_orig_argv': ['./argv0', '-E', '-c', 'pass', 'arg1', '-v', 'arg3'],
|
||||
'program_name': './argv0',
|
||||
'run_command': 'pass\n',
|
||||
'use_environment': 0,
|
||||
|
@ -1012,6 +1032,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'],
|
||||
'program_name': './argv0',
|
||||
}
|
||||
self.check_all_configs("test_init_dont_parse_argv", config, pre_config,
|
||||
|
@ -1299,10 +1320,17 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
|||
'faulthandler': 1,
|
||||
'bytes_warning': 1,
|
||||
'warnoptions': warnoptions,
|
||||
'_orig_argv': ['python3',
|
||||
'-Wignore:::cmdline1',
|
||||
'-Wignore:::cmdline2'],
|
||||
}
|
||||
self.check_all_configs("test_init_warnoptions", config, preconfig,
|
||||
api=API_PYTHON)
|
||||
|
||||
def test_get_argc_argv(self):
|
||||
self.run_embedded_interpreter("test_get_argc_argv")
|
||||
# ignore output
|
||||
|
||||
|
||||
class AuditingTests(EmbeddingTestsMixin, unittest.TestCase):
|
||||
def test_open_code_hook(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue