aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_source_encoding.py
diff options
context:
space:
mode:
authorPablo Galindo Salgado <Pablogsal@gmail.com>2022-11-30 11:36:06 +0000
committerGitHub <noreply@github.com>2022-11-30 03:36:06 -0800
commit417206a05c4545bde96c2bbbea92b53e6cac0d48 (patch)
tree8b989a93e86d20ab9fbc2bce1912496552575835 /Lib/test/test_source_encoding.py
parent19c38801ba2f42a220adece5d5f12e833b41822a (diff)
downloadcpython-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.py12
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):