From 85ac3725836f42f701b47f65bb6c9d00617c46e0 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Tue, 20 Nov 2018 15:39:26 -0700 Subject: [PATCH 1/2] bpo-35284: Fix the error handling in the compiler's compiler_call() compiler_call() needs to check if an error occurred during the maybe_optimize_method_call() call. --- Python/compile.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index beceeea86b12d03..3a1630e906dce94 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -3622,8 +3622,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; + } VISIT(c, expr, e->v.Call.func); return compiler_call_helper(c, 0, From 1a96c69200918dbe85b365552f395707b7122c73 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Thu, 21 Mar 2019 17:09:48 -0600 Subject: [PATCH 2/2] Tweak the comment. --- Python/compile.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index ed7f106db0cfa0b..a992e4b4653cc18 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -3879,9 +3879,7 @@ check_index(struct compiler *c, expr_ty e, slice_ty s) } } -/* Try to compile optimized memory call. - Returns 0 on error, -1 if cannot optimize, 1 if successfully optimized. - */ +// 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) {