mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-42260: PyConfig_Read() only parses argv once (GH-23168)
The PyConfig_Read() function now only parses PyConfig.argv arguments once: PyConfig.parse_argv is set to 2 after arguments are parsed. Since Python arguments are strippped from PyConfig.argv, parsing arguments twice would parse the application options as Python options. * Rework the PyConfig documentation. * Fix _testinternalcapi.set_config() error handling. * SetConfigTests no longer needs parse_argv=0 when restoring the old configuration.
This commit is contained in:
parent
f3cb814315
commit
dc42af8fd1
6 changed files with 131 additions and 102 deletions
|
@ -422,7 +422,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
|||
CONFIG_PYTHON = dict(CONFIG_COMPAT,
|
||||
_config_init=API_PYTHON,
|
||||
configure_c_stdio=1,
|
||||
parse_argv=1,
|
||||
parse_argv=2,
|
||||
)
|
||||
CONFIG_ISOLATED = dict(CONFIG_COMPAT,
|
||||
_config_init=API_ISOLATED,
|
||||
|
@ -800,7 +800,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
|||
'-X', 'cmdline_xoption',
|
||||
'-c', 'pass',
|
||||
'arg2'],
|
||||
'parse_argv': 1,
|
||||
'parse_argv': 2,
|
||||
'xoptions': [
|
||||
'config_xoption1=3',
|
||||
'config_xoption2=',
|
||||
|
@ -1045,7 +1045,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
|||
'orig_argv': ['python3', '-c', code, 'arg2'],
|
||||
'program_name': './python3',
|
||||
'run_command': code + '\n',
|
||||
'parse_argv': 1,
|
||||
'parse_argv': 2,
|
||||
}
|
||||
self.check_all_configs("test_init_run_main", config, api=API_PYTHON)
|
||||
|
||||
|
@ -1059,7 +1059,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
|||
'arg2'],
|
||||
'program_name': './python3',
|
||||
'run_command': code + '\n',
|
||||
'parse_argv': 1,
|
||||
'parse_argv': 2,
|
||||
'_init_main': 0,
|
||||
}
|
||||
self.check_all_configs("test_init_main", config,
|
||||
|
@ -1068,7 +1068,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
|||
|
||||
def test_init_parse_argv(self):
|
||||
config = {
|
||||
'parse_argv': 1,
|
||||
'parse_argv': 2,
|
||||
'argv': ['-c', 'arg1', '-v', 'arg3'],
|
||||
'orig_argv': ['./argv0', '-E', '-c', 'pass', 'arg1', '-v', 'arg3'],
|
||||
'program_name': './argv0',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue