Skip to content

Commit 5e3eeec

Browse files
committed
address review
1 parent 825c75d commit 5e3eeec

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

Python/ast_opt.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,6 @@ astfold_expr(expr_ty node_, PyArena *ctx_, _PyASTOptimizeState *state)
803803
case Subscript_kind:
804804
CALL(astfold_expr, expr_ty, node_->v.Subscript.value);
805805
CALL(astfold_expr, expr_ty, node_->v.Subscript.slice);
806-
/* Subscript folding is now done in flowgraph.c (optimize_if_const_subscr) */
807806
break;
808807
case Starred_kind:
809808
CALL(astfold_expr, expr_ty, node_->v.Starred.value);

Python/flowgraph.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,6 @@
2121
return ERROR; \
2222
}
2323

24-
#define RETURN_IF_FOLD_FAIL(X) \
25-
if ((X) == NULL) { \
26-
if (PyErr_ExceptionMatches(PyExc_KeyboardInterrupt)) { \
27-
return ERROR; \
28-
} \
29-
PyErr_Clear(); \
30-
return SUCCESS; \
31-
}
32-
3324
#define DEFAULT_BLOCK_SIZE 16
3425

3526
typedef _Py_SourceLocation location;
@@ -1515,7 +1506,13 @@ optimize_if_const_subscr(basicblock *bb, int n, PyObject *consts, PyObject *cons
15151506
return ERROR;
15161507
}
15171508
PyObject *newconst = PyObject_GetItem(o, key);
1518-
RETURN_IF_FOLD_FAIL(newconst);
1509+
if (newconst == NULL) {
1510+
if (PyErr_ExceptionMatches(PyExc_KeyboardInterrupt)) {
1511+
return ERROR;
1512+
}
1513+
PyErr_Clear();
1514+
return SUCCESS;
1515+
}
15191516
int newopcode, newoparg;
15201517
RETURN_IF_ERROR(newop_from_folded(newconst, consts, const_cache, &newopcode, &newoparg));
15211518
INSTR_SET_OP1(subscr, newopcode, newoparg);

0 commit comments

Comments
 (0)