Skip to content

Commit

Permalink
bpo-43202: Immediately return code object in codeop._maybe_compile (G…
Browse files Browse the repository at this point in the history
…H-24508)

The return used to be after code that was ignored when there was a code object.
  • Loading branch information
terryjreedy committed Feb 12, 2021
1 parent fedd86d commit 2068b26
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions Lib/codeop.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ def _maybe_compile(compiler, source, filename, symbol):
source = "pass" # Replace it with a 'pass' statement

err = err1 = err2 = None
code = code1 = code2 = None
code1 = code2 = None

try:
code = compiler(source, filename, symbol)
return compiler(source, filename, symbol)
except SyntaxError:
pass

Expand All @@ -100,8 +100,6 @@ def _maybe_compile(compiler, source, filename, symbol):
err2 = e

try:
if code:
return code
if not code1 and _is_syntax_error(err1, err2):
raise err1
finally:
Expand Down

0 comments on commit 2068b26

Please sign in to comment.