diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2014-01-21 22:29:47 +0200 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2014-01-21 22:29:47 +0200 |
commit | 2bd59daf58431284e13f3e080a52cab032eb792f (patch) | |
tree | f84cc2dee484690fc0641850a7f64042583bb033 /Lib/test/test_exceptions.py | |
parent | 567b26e882a3a73f37f69390f3a34ec533ff4590 (diff) | |
parent | 65fd0592fb3845c17b27c441380553fc22f78812 (diff) | |
download | cpython-git-2bd59daf58431284e13f3e080a52cab032eb792f.tar.gz |
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.
Diffstat (limited to 'Lib/test/test_exceptions.py')
-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 f0851bdbe2..4770dfd43e 100644 --- a/Lib/test/test_exceptions.py +++ b/Lib/test/test_exceptions.py @@ -148,6 +148,19 @@ class ExceptionTests(unittest.TestCase): ckmsg(s, "'continue' not properly in loop") ckmsg("continue\n", "'continue' not properly in loop") + def testSyntaxErrorOffset(self): + def check(src, lineno, offset): + with self.assertRaises(SyntaxError) as cm: + compile(src, '<fragment>', 'exec') + self.assertEqual(cm.exception.lineno, lineno) + self.assertEqual(cm.exception.offset, offset) + + check('def fact(x):\n\treturn x!\n', 2, 10) + check('1 +\n', 1, 4) + check('def spam():\n print(1)\n print(2)', 3, 10) + check('Python = "Python" +', 1, 20) + check('Python = "\u1e54\xfd\u0163\u0125\xf2\xf1" +', 1, 20) + @cpython_only def testSettingException(self): # test that setting an exception at the C level works even if the |