diff --git a/Lib/idlelib/EditorWindow.py b/Lib/idlelib/EditorWindow.py index aed4d6acda6..565cf367e20 100644 --- a/Lib/idlelib/EditorWindow.py +++ b/Lib/idlelib/EditorWindow.py @@ -1621,7 +1621,7 @@ class IndentSearcher(object): tokens = _tokenize.generate_tokens(self.readline) for token in tokens: self.tokeneater(*token) - except _tokenize.TokenError: + except (_tokenize.TokenError, SyntaxError): # since we cut off the tokenizer early, we can trigger # spurious errors pass diff --git a/Misc/NEWS b/Misc/NEWS index 0dcecfef8ad..8786b618445 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -193,6 +193,9 @@ Core and Builtins Library ------- +- Issue #16504: IDLE now catches SyntaxErrors raised by tokenizer. Patch by + Roger Serwy. + - Issue #16618: Make glob.glob match consistently across strings and bytes regarding leading dots. Patch by Serhiy Storchaka.