bpo-40334: Rename PyConfig.use_peg to _use_peg_parser (GH-19670)

* Rename PyConfig.use_peg to _use_peg_parser
* Document PyConfig._use_peg_parser and mark it a deprecated
* Mark -X oldparser option and PYTHONOLDPARSER env var as deprecated
  in the documentation.
* Add use_old_parser() and skip_if_new_parser() to test.support
* Remove sys.flags.use_peg: use_old_parser() uses
  _testinternalcapi.get_configs() instead.
* Enhance test_embed tests
* subprocess._args_from_interpreter_flags() copies -X oldparser
This commit is contained in:
Victor Stinner 2020-04-23 03:03:24 +02:00 committed by GitHub
parent a25f3c4c8f
commit 1def7754b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 83 additions and 54 deletions

View file

@ -33,6 +33,7 @@ import shutil
import tempfile
import unittest
import warnings
from test.support import check_syntax_warning, use_old_parser
TEMPLATE = r"""# coding: %s
@ -63,8 +64,6 @@ def byte(i):
class TestLiterals(unittest.TestCase):
from test.support import check_syntax_warning
def setUp(self):
self.save_path = sys.path[:]
self.tmpdir = tempfile.mkdtemp()
@ -119,7 +118,7 @@ class TestLiterals(unittest.TestCase):
eval("'''\n\\z'''")
self.assertEqual(len(w), 1)
self.assertEqual(w[0].filename, '<string>')
if not sys.flags.use_peg:
if use_old_parser():
self.assertEqual(w[0].lineno, 1)
with warnings.catch_warnings(record=True) as w:
@ -129,7 +128,7 @@ class TestLiterals(unittest.TestCase):
exc = cm.exception
self.assertEqual(w, [])
self.assertEqual(exc.filename, '<string>')
if not sys.flags.use_peg:
if use_old_parser():
self.assertEqual(exc.lineno, 1)
def test_eval_str_raw(self):
@ -170,7 +169,7 @@ class TestLiterals(unittest.TestCase):
eval("b'''\n\\z'''")
self.assertEqual(len(w), 1)
self.assertEqual(w[0].filename, '<string>')
if not sys.flags.use_peg:
if use_old_parser():
self.assertEqual(w[0].lineno, 1)
with warnings.catch_warnings(record=True) as w:
@ -180,7 +179,7 @@ class TestLiterals(unittest.TestCase):
exc = cm.exception
self.assertEqual(w, [])
self.assertEqual(exc.filename, '<string>')
if not sys.flags.use_peg:
if use_old_parser():
self.assertEqual(exc.lineno, 1)
def test_eval_bytes_raw(self):