summaryrefslogtreecommitdiffstats
path: root/Lib/codeop.py
diff options
context:
space:
mode:
authorPablo Galindo Salgado <Pablogsal@gmail.com>2024-01-30 16:21:30 (GMT)
committerGitHub <noreply@github.com>2024-01-30 16:21:30 (GMT)
commit39d102c2ee8eec8ab0bacbcd62d62a72742ecc7c (patch)
treef1dab9719fa4b0bda6f06be2b6f99465053761d9 /Lib/codeop.py
parent1f515e8a109204f7399d85b7fd806135166422d9 (diff)
downloadcpython-39d102c2ee8eec8ab0bacbcd62d62a72742ecc7c.zip
cpython-39d102c2ee8eec8ab0bacbcd62d62a72742ecc7c.tar.gz
cpython-39d102c2ee8eec8ab0bacbcd62d62a72742ecc7c.tar.bz2
gh-113744: Add a new IncompleteInputError exception to improve incomplete input detection in the codeop module (#113745)
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
Diffstat (limited to 'Lib/codeop.py')
-rw-r--r--Lib/codeop.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/codeop.py b/Lib/codeop.py
index 91146be..6ad60e7 100644
--- a/Lib/codeop.py
+++ b/Lib/codeop.py
@@ -65,9 +65,10 @@ def _maybe_compile(compiler, source, filename, symbol):
try:
compiler(source + "\n", filename, symbol)
return None
+ except IncompleteInputError as e:
+ return None
except SyntaxError as e:
- if "incomplete input" in str(e):
- return None
+ pass
# fallthrough
return compiler(source, filename, symbol, incomplete_input=False)