◐ Shell
clean mode source ↗

[3.7] bpo-40807: Show warnings once from codeop._maybe_compile (GH-20486) by miss-islington · Pull Request #20641 · python/cpython

Expand Up @@ -57,6 +57,7 @@ """
import __future__ import warnings
_features = [getattr(__future__, fname) for fname in __future__.all_feature_names] Expand All @@ -83,15 +84,18 @@ def _maybe_compile(compiler, source, filename, symbol): except SyntaxError as err: pass
try: code1 = compiler(source + "\n", filename, symbol) except SyntaxError as e: err1 = e
try: code2 = compiler(source + "\n\n", filename, symbol) except SyntaxError as e: err2 = e # Suppress warnings after the first compile to avoid duplication. with warnings.catch_warnings(): warnings.simplefilter("ignore") try: code1 = compiler(source + "\n", filename, symbol) except SyntaxError as e: err1 = e
try: code2 = compiler(source + "\n\n", filename, symbol) except SyntaxError as e: err2 = e
try: if code: Expand Down