Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Lib/test/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ def check(self, src, lineno, offset, encoding='utf-8'):
line = src.split('\n')[lineno-1]
self.assertIn(line, cm.exception.text)

def test_error_offset_continuation_characters(self):
check = self.check
check('"\\\n"(1 for c in I,\\\n\\', 3, 22)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unfortunately a regression:

>>> try:
...   compile('"\\\n"(1 for c in I,\\\n\\', "", "exec")
... except SyntaxError as e:
...   f = e
...
>>> f.lineno
2
>>> f.offset
3


def testSyntaxErrorOffset(self):
check = self.check
check('def fact(x):\n\treturn x!\n', 2, 10)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix parser crash when reporting errors involving invalid continuation
characters. Patch by Pablo Galindo.
Loading