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.
diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py
index 9182061..a7d9121 100644
--- a/Lib/test/test_embed.py
+++ b/Lib/test/test_embed.py
@@ -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 @@ def test_init_from_config(self):
'-X', 'cmdline_xoption',
'-c', 'pass',
'arg2'],
- 'parse_argv': 1,
+ 'parse_argv': 2,
'xoptions': [
'config_xoption1=3',
'config_xoption2=',
@@ -1045,7 +1045,7 @@ def test_init_run_main(self):
'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 @@ def test_init_main(self):
'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 @@ def test_init_main(self):
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',