mirror of
https://github.com/python/cpython.git
synced 2025-07-09 20:35:26 +00:00
gh-133541: Handle SyntaxError raised by the tokenizer on user input (#133606)
This commit is contained in:
parent
6ce469dcba
commit
b2fabce6ab
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