summaryrefslogtreecommitdiffstats
path: root/Lib/test/_test_embed_set_config.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-11-05 17:58:07 (GMT)
committerGitHub <noreply@github.com>2020-11-05 17:58:07 (GMT)
commitdc42af8fd16b10127ce1fc93c13bc1bfd2674aa2 (patch)
tree4d45407632e738acb07a54af480d16c7fadef8b4 /Lib/test/_test_embed_set_config.py
parentf3cb81431574453aac3b6dcadb3120331e6a8f1c (diff)
downloadcpython-dc42af8fd16b10127ce1fc93c13bc1bfd2674aa2.zip
cpython-dc42af8fd16b10127ce1fc93c13bc1bfd2674aa2.tar.gz
cpython-dc42af8fd16b10127ce1fc93c13bc1bfd2674aa2.tar.bz2
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.
Diffstat (limited to 'Lib/test/_test_embed_set_config.py')
-rw-r--r--Lib/test/_test_embed_set_config.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/test/_test_embed_set_config.py b/Lib/test/_test_embed_set_config.py
index 7c91381..a19f8db 100644
--- a/Lib/test/_test_embed_set_config.py
+++ b/Lib/test/_test_embed_set_config.py
@@ -20,7 +20,7 @@ class SetConfigTests(unittest.TestCase):
self.sys_copy = dict(sys.__dict__)
def tearDown(self):
- self.set_config(parse_argv=0)
+ _testinternalcapi.set_config(self.old_config)
sys.__dict__.clear()
sys.__dict__.update(self.sys_copy)
@@ -234,6 +234,12 @@ class SetConfigTests(unittest.TestCase):
self.assertEqual(sys.argv, ['python_program', 'args'])
self.assertEqual(sys.orig_argv, ['orig', 'orig_args'])
+ self.set_config(parse_argv=0,
+ argv=[],
+ orig_argv=[])
+ self.assertEqual(sys.argv, [''])
+ self.assertEqual(sys.orig_argv, [])
+
def test_pycache_prefix(self):
self.check(pycache_prefix=None)
self.check(pycache_prefix="pycache_prefix")