diff options
author | Pablo Galindo <Pablogsal@gmail.com> | 2021-02-09 20:07:38 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-09 20:07:38 +0000 |
commit | dbb228189b4eb7ab41f326eb79dae669b2c81177 (patch) | |
tree | c4338eabaed5b9ece25fda84b4ca035283f1466a /Lib/codeop.py | |
parent | bpo-43166: Disable ceval.c optimisations for Windows debug builds (GH-24485) (diff) | |
download | cpython-dbb228189b4eb7ab41f326eb79dae669b2c81177.tar.gz cpython-dbb228189b4eb7ab41f326eb79dae669b2c81177.tar.bz2 cpython-dbb228189b4eb7ab41f326eb79dae669b2c81177.zip |
bpo-43163: Handle unclosed parentheses in codeop (GH-24483)
Diffstat (limited to 'Lib/codeop.py')
-rw-r--r-- | Lib/codeop.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/Lib/codeop.py b/Lib/codeop.py index 4c10470aee7..7a08610239c 100644 --- a/Lib/codeop.py +++ b/Lib/codeop.py @@ -102,11 +102,20 @@ def _maybe_compile(compiler, source, filename, symbol): try: if code: return code - if not code1 and repr(err1) == repr(err2): + if not code1 and _is_syntax_error(err1, err2): raise err1 finally: err1 = err2 = None +def _is_syntax_error(err1, err2): + rep1 = repr(err1) + rep2 = repr(err2) + if "was never closed" in rep1 and "was never closed" in rep2: + return False + if rep1 == rep2: + return True + return False + def _compile(source, filename, symbol): return compile(source, filename, symbol, PyCF_DONT_IMPLY_DEDENT) |