mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +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
|
@ -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")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue