]> granicus.if.org Git - python/commitdiff
bpo-35284: Fix the error handling in the compiler's compiler_call(). (GH-10625)
authorZackery Spytz <zspytz@gmail.com>
Fri, 22 Mar 2019 07:30:32 +0000 (01:30 -0600)
committerSerhiy Storchaka <storchaka@gmail.com>
Fri, 22 Mar 2019 07:30:32 +0000 (09:30 +0200)
compiler_call() needs to check if an error occurred during the
maybe_optimize_method_call() call.

Python/compile.c

index 3656a7e00efd939ce027b54572a5efdad2f34dc3..a992e4b4653cc18cd710847bfcdbf0435f8c4925 100644 (file)
@@ -3879,6 +3879,7 @@ check_index(struct compiler *c, expr_ty e, slice_ty s)
     }
 }
 
+// Return 1 if the method call was optimized, -1 if not, and 0 on error.
 static int
 maybe_optimize_method_call(struct compiler *c, expr_ty e)
 {
@@ -3912,8 +3913,10 @@ maybe_optimize_method_call(struct compiler *c, expr_ty e)
 static int
 compiler_call(struct compiler *c, expr_ty e)
 {
-    if (maybe_optimize_method_call(c, e) > 0)
-        return 1;
+    int ret = maybe_optimize_method_call(c, e);
+    if (ret >= 0) {
+        return ret;
+    }
     if (!check_caller(c, e->v.Call.func)) {
         return 0;
     }