diff options
author | Pablo Galindo Salgado <Pablogsal@gmail.com> | 2022-11-30 11:36:06 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-30 03:36:06 -0800 |
commit | 417206a05c4545bde96c2bbbea92b53e6cac0d48 (patch) | |
tree | 8b989a93e86d20ab9fbc2bce1912496552575835 /Lib/test/test_source_encoding.py | |
parent | 19c38801ba2f42a220adece5d5f12e833b41822a (diff) | |
download | cpython-417206a05c4545bde96c2bbbea92b53e6cac0d48.tar.gz cpython-417206a05c4545bde96c2bbbea92b53e6cac0d48.zip |
gh-99891: Fix infinite recursion in the tokenizer when showing warnings (GH-99893)
Automerge-Triggered-By: GH:pablogsal
Diffstat (limited to 'Lib/test/test_source_encoding.py')
-rw-r--r-- | Lib/test/test_source_encoding.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_source_encoding.py b/Lib/test/test_source_encoding.py index cfc4b13f18f..b05173ad00d 100644 --- a/Lib/test/test_source_encoding.py +++ b/Lib/test/test_source_encoding.py @@ -160,6 +160,18 @@ class MiscSourceEncodingTest(unittest.TestCase): finally: os.unlink(TESTFN) + def test_tokenizer_fstring_warning_in_first_line(self): + source = "0b1and 2" + with open(TESTFN, "w") as fd: + fd.write("{}".format(source)) + try: + retcode, stdout, stderr = script_helper.assert_python_ok(TESTFN) + self.assertIn(b"SyntaxWarning: invalid binary litera", stderr) + self.assertEqual(stderr.count(source.encode()), 1) + finally: + os.unlink(TESTFN) + + class AbstractSourceEncodingTest: def test_default_coding(self): |