]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-43202: Immediately return code object in codeop._maybe_compile (GH-24508)
authorTerry Jan Reedy <tjreedy@udel.edu>
Fri, 12 Feb 2021 00:31:10 +0000 (19:31 -0500)
committerGitHub <noreply@github.com>
Fri, 12 Feb 2021 00:31:10 +0000 (19:31 -0500)
The return used to be after code that was ignored when there was a code object.

Lib/codeop.py

index 7a08610239c3571ee5207eb2f4515ddda3b75e66..b3af93f1e18f592407dce7ef8e3fb63977b3d4f2 100644 (file)
@@ -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
 
@@ -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: