summaryrefslogtreecommitdiffstats
path: root/Lib/codeop.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2020-08-12 13:13:09 (GMT)
committerGitHub <noreply@github.com>2020-08-12 13:13:09 (GMT)
commit90eff4ed4445a0fa9d8cdf74c0f86c50ed510dad (patch)
tree4fd7a494697ab690eb79ed6166716521763ad48e /Lib/codeop.py
parent6e21a3021590ef0f4869d192e6478d6f78aa3f2a (diff)
downloadcpython-90eff4ed4445a0fa9d8cdf74c0f86c50ed510dad.zip
cpython-90eff4ed4445a0fa9d8cdf74c0f86c50ed510dad.tar.gz
cpython-90eff4ed4445a0fa9d8cdf74c0f86c50ed510dad.tar.bz2
bpo-41520: codeop no longer ignores SyntaxWarning (GH-21838)
(cherry picked from commit 369a1cbdee14d9f27356fb3a8bb21e4fde289d25) Co-authored-by: Victor Stinner <vstinner@python.org>
Diffstat (limited to 'Lib/codeop.py')
-rw-r--r--Lib/codeop.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/codeop.py b/Lib/codeop.py
index 7e192ea..5476292 100644
--- a/Lib/codeop.py
+++ b/Lib/codeop.py
@@ -84,9 +84,11 @@ def _maybe_compile(compiler, source, filename, symbol):
except SyntaxError:
pass
- # Suppress warnings after the first compile to avoid duplication.
+ # Catch syntax warnings after the first compile
+ # to emit SyntaxWarning at most once.
with warnings.catch_warnings():
- warnings.simplefilter("ignore")
+ warnings.simplefilter("error", SyntaxWarning)
+
try:
code1 = compiler(source + "\n", filename, symbol)
except SyntaxError as e: