mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
bpo-40593: Improve syntax errors for invalid characters in source code. (GH-20033)
This commit is contained in:
parent
f3a5b7ada0
commit
74ea6b5a75
10 changed files with 92 additions and 45 deletions
|
@ -20,9 +20,11 @@ class PEP3131Test(unittest.TestCase):
|
|||
def test_invalid(self):
|
||||
try:
|
||||
from test import badsyntax_3131
|
||||
except SyntaxError as s:
|
||||
self.assertEqual(str(s),
|
||||
"invalid character in identifier (badsyntax_3131.py, line 2)")
|
||||
except SyntaxError as err:
|
||||
self.assertEqual(str(err),
|
||||
"invalid character '€' (U+20AC) (badsyntax_3131.py, line 2)")
|
||||
self.assertEqual(err.lineno, 2)
|
||||
self.assertEqual(err.offset, 1)
|
||||
else:
|
||||
self.fail("expected exception didn't occur")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue