Skip to content

Commit b27f916

Browse files
committed
Address code review
1 parent e68dc65 commit b27f916

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Python/specialize.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2716,6 +2716,7 @@ _Py_Specialize_ToBool(_PyStackRef value_o, _Py_CODEUNIT *instr)
27162716
assert(_PyOpcode_Caches[TO_BOOL] == INLINE_CACHE_ENTRIES_TO_BOOL);
27172717
_PyToBoolCache *cache = (_PyToBoolCache *)(instr + 1);
27182718
PyObject *value = PyStackRef_AsPyObjectBorrow(value_o);
2719+
int reason;
27192720
uint8_t specialized_op;
27202721
if (PyBool_Check(value)) {
27212722
specialized_op = TO_BOOL_BOOL;
@@ -2741,12 +2742,12 @@ _Py_Specialize_ToBool(_PyStackRef value_o, _Py_CODEUNIT *instr)
27412742
unsigned int version = 0;
27422743
int err = _PyType_Validate(Py_TYPE(value), check_type_always_true, &version);
27432744
if (err < 0) {
2744-
unspecialize(instr, SPEC_FAIL_OUT_OF_VERSIONS);
2745-
return;
2745+
reason = SPEC_FAIL_OUT_OF_VERSIONS;
2746+
goto fail;
27462747
}
27472748
else if (err > 0) {
2748-
unspecialize(instr, err);
2749-
return;
2749+
reason = err;
2750+
goto fail;
27502751
}
27512752

27522753
assert(err == 0);
@@ -2755,7 +2756,9 @@ _Py_Specialize_ToBool(_PyStackRef value_o, _Py_CODEUNIT *instr)
27552756
specialized_op = TO_BOOL_ALWAYS_TRUE;
27562757
goto success;
27572758
}
2758-
unspecialize(instr, to_bool_fail_kind(value));
2759+
reason = to_bool_fail_kind(value);
2760+
fail:
2761+
unspecialize(instr, reason);
27592762
return;
27602763
success:
27612764
specialize(instr, specialized_op);

0 commit comments

Comments
 (0)