summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_utf8_mode.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2018-01-25 08:18:36 (GMT)
committerGitHub <noreply@github.com>2018-01-25 08:18:36 (GMT)
commit2b822a0bb1de2612c85d8f75e3ce89eda2ac9f68 (patch)
tree0a1e50226a88d81f177e075ce91eb0499807c57a /Lib/test/test_utf8_mode.py
parentcab0b2b053970982b760048acc3046363615a8dd (diff)
downloadcpython-2b822a0bb1de2612c85d8f75e3ce89eda2ac9f68.zip
cpython-2b822a0bb1de2612c85d8f75e3ce89eda2ac9f68.tar.gz
cpython-2b822a0bb1de2612c85d8f75e3ce89eda2ac9f68.tar.bz2
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.
Diffstat (limited to 'Lib/test/test_utf8_mode.py')
-rw-r--r--Lib/test/test_utf8_mode.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_utf8_mode.py b/Lib/test/test_utf8_mode.py
index 73d1bd4..26e2e13 100644
--- a/Lib/test/test_utf8_mode.py
+++ b/Lib/test/test_utf8_mode.py
@@ -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()