mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Issue #2382: SyntaxError cursor "^" now is written at correct position in most
cases when multibyte characters are in line (before "^"). This still not works correctly with wide East Asian characters.
This commit is contained in:
commit
2bd59daf58
4 changed files with 38 additions and 2 deletions
|
@ -32,6 +32,9 @@ class SyntaxTracebackCases(unittest.TestCase):
|
|||
def syntax_error_bad_indentation(self):
|
||||
compile("def spam():\n print(1)\n print(2)", "?", "exec")
|
||||
|
||||
def syntax_error_with_caret_non_ascii(self):
|
||||
compile('Python = "\u1e54\xfd\u0163\u0125\xf2\xf1" +', "?", "exec")
|
||||
|
||||
def test_caret(self):
|
||||
err = self.get_exception_format(self.syntax_error_with_caret,
|
||||
SyntaxError)
|
||||
|
@ -46,6 +49,12 @@ class SyntaxTracebackCases(unittest.TestCase):
|
|||
self.assertTrue(err[2].count('\n') == 1) # and no additional newline
|
||||
self.assertTrue(err[1].find("+") == err[2].find("^")) # in the right place
|
||||
|
||||
err = self.get_exception_format(self.syntax_error_with_caret_non_ascii,
|
||||
SyntaxError)
|
||||
self.assertIn("^", err[2]) # third line has caret
|
||||
self.assertTrue(err[2].count('\n') == 1) # and no additional newline
|
||||
self.assertTrue(err[1].find("+") == err[2].find("^")) # in the right place
|
||||
|
||||
def test_nocaret(self):
|
||||
exc = SyntaxError("error", ("x.py", 23, None, "bad syntax"))
|
||||
err = traceback.format_exception_only(SyntaxError, exc)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue