diff options
author | Pablo Galindo Salgado <Pablogsal@gmail.com> | 2021-11-20 14:36:07 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-20 14:36:07 (GMT) |
commit | fdcc46d9554094994f78bedf6dc9220e5d5ee668 (patch) | |
tree | 4f8dbf3fc78bf76311d63c84a5c2384c9fd089d9 /Lib | |
parent | 6d430ef5ab62158a200b94dff31b89524a9576bb (diff) | |
download | cpython-fdcc46d9554094994f78bedf6dc9220e5d5ee668.zip cpython-fdcc46d9554094994f78bedf6dc9220e5d5ee668.tar.gz cpython-fdcc46d9554094994f78bedf6dc9220e5d5ee668.tar.bz2 |
bpo-45848: Allow the parser to get error lines from encoded files (GH-29646)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_exceptions.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py index 1341f77..4c18a59 100644 --- a/Lib/test/test_exceptions.py +++ b/Lib/test/test_exceptions.py @@ -2353,6 +2353,19 @@ class SyntaxErrorTests(unittest.TestCase): finally: unlink(TESTFN) + # Check backwards tokenizer errors + source = '# -*- coding: ascii -*-\n\n(\n' + try: + with open(TESTFN, 'w', encoding='ascii') as testfile: + testfile.write(source) + rc, out, err = script_helper.assert_python_failure('-Wd', '-X', 'utf8', TESTFN) + err = err.decode('utf-8').splitlines() + + self.assertEqual(err[-3], ' (') + self.assertEqual(err[-2], ' ^') + finally: + unlink(TESTFN) + def test_attributes_new_constructor(self): args = ("bad.py", 1, 2, "abcdefg", 1, 100) the_exception = SyntaxError("bad bad", args) |