Skip to content

Commit 7b7a21b

Browse files
lysnikolaougvanrossumpablogsal
authored
bpo-40661: Fix segfault when parsing invalid input (GH-20165)
Fix segfaults when parsing very complex invalid input, like `import äˆ ð£„¯ð¢·žð±‹á”€ð””ð‘©±å®ä±¬ð©¾\nð—¶½`. Co-authored-by: Guido van Rossum <[email protected]> Co-authored-by: Pablo Galindo <[email protected]>
1 parent 08b47c3 commit 7b7a21b

4 files changed

Lines changed: 1603 additions & 8 deletions

File tree

‎Lib/test/test_peg_parser.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,7 @@ def f(*a, b):
591591
("f-string_single_closing_brace", "f'}'"),
592592
("from_import_invalid", "from import import a"),
593593
("from_import_trailing_comma", "from a import b,"),
594+
("import_non_ascii_syntax_error", "import ä £"),
594595
# This test case checks error paths involving tokens with uninitialized
595596
# values of col_offset and end_col_offset.
596597
("invalid indentation",

‎Lib/test/test_syntax.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,9 @@
659659
Traceback (most recent call last):
660660
SyntaxError: cannot assign to __debug__
661661
662+
>>> import ä £
663+
Traceback (most recent call last):
664+
SyntaxError: invalid character '£' (U+00A3)
662665
"""
663666

664667
import re

0 commit comments

Comments
 (0)