mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
[3.14] gh-133541: Handle SyntaxError raised by the tokenizer on user input (GH-133606) (#133709)
This commit is contained in:
parent
add970f08e
commit
0c340d1083
3 changed files with 24 additions and 0 deletions
|
@ -102,6 +102,8 @@ def gen_colors(buffer: str) -> Iterator[ColorSpan]:
|
|||
for color in gen_colors_from_token_stream(gen, line_lengths):
|
||||
yield color
|
||||
last_emitted = color
|
||||
except SyntaxError:
|
||||
return
|
||||
except tokenize.TokenError as te:
|
||||
yield from recover_unterminated_string(
|
||||
te, line_lengths, last_emitted, buffer
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue