mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
bpo-32652: Defer pymain_set_global_config() call (#5303)
In Py_Main(), don't call pymain_set_global_config() early: only call it when the whole configuration has been read. Add an unit test to prevent future regression.
This commit is contained in:
parent
cab0b2b053
commit
2b822a0bb1
2 changed files with 27 additions and 14 deletions
|
@ -223,6 +223,21 @@ class UTF8ModeTests(unittest.TestCase):
|
|||
c_arg = arg_ascii
|
||||
check('utf8=0', [c_arg], LC_ALL='C')
|
||||
|
||||
def test_optim_level(self):
|
||||
# CPython: check that Py_Main() doesn't increment Py_OptimizeFlag
|
||||
# twice when -X utf8 requires to parse the configuration twice (when
|
||||
# the encoding changes after reading the configuration, the
|
||||
# configuration is read again with the new encoding).
|
||||
code = 'import sys; print(sys.flags.optimize)'
|
||||
out = self.get_output('-X', 'utf8', '-O', '-c', code)
|
||||
self.assertEqual(out, '1')
|
||||
out = self.get_output('-X', 'utf8', '-OO', '-c', code)
|
||||
self.assertEqual(out, '2')
|
||||
|
||||
code = 'import sys; print(sys.flags.ignore_environment)'
|
||||
out = self.get_output('-X', 'utf8', '-E', '-c', code)
|
||||
self.assertEqual(out, '1')
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue