mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
bpo-40910: Export Py_GetArgcArgv() function (GH-20721) (GH-20723)
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().
(cherry picked from commit e81f6e687d
)
This commit is contained in:
parent
1220a47079
commit
dedaac040f
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': [],
|
||||
|
@ -737,7 +738,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',
|
||||
|
@ -864,6 +870,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,
|
||||
|
@ -878,9 +885,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,
|
||||
|
@ -959,6 +971,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)
|
||||
|
||||
|
@ -967,6 +982,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,
|
||||
|
@ -978,6 +994,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,
|
||||
|
@ -991,6 +1010,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,
|
||||
|
@ -1004,6 +1024,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,
|
||||
|
@ -1291,10 +1312,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