From b27f9166335ea5af50985234ba37f8f468210d1f Mon Sep 17 00:00:00 2001 From: Donghee Na Date: Sat, 16 Nov 2024 11:34:14 +0900 Subject: [PATCH] Address code review --- Python/specialize.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Python/specialize.c b/Python/specialize.c index 35ea4df81fd761..e46b34ecc32e61 100644 --- a/Python/specialize.c +++ b/Python/specialize.c @@ -2716,6 +2716,7 @@ _Py_Specialize_ToBool(_PyStackRef value_o, _Py_CODEUNIT *instr) assert(_PyOpcode_Caches[TO_BOOL] == INLINE_CACHE_ENTRIES_TO_BOOL); _PyToBoolCache *cache = (_PyToBoolCache *)(instr + 1); PyObject *value = PyStackRef_AsPyObjectBorrow(value_o); + int reason; uint8_t specialized_op; if (PyBool_Check(value)) { specialized_op = TO_BOOL_BOOL; @@ -2741,12 +2742,12 @@ _Py_Specialize_ToBool(_PyStackRef value_o, _Py_CODEUNIT *instr) unsigned int version = 0; int err = _PyType_Validate(Py_TYPE(value), check_type_always_true, &version); if (err < 0) { - unspecialize(instr, SPEC_FAIL_OUT_OF_VERSIONS); - return; + reason = SPEC_FAIL_OUT_OF_VERSIONS; + goto fail; } else if (err > 0) { - unspecialize(instr, err); - return; + reason = err; + goto fail; } assert(err == 0); @@ -2755,7 +2756,9 @@ _Py_Specialize_ToBool(_PyStackRef value_o, _Py_CODEUNIT *instr) specialized_op = TO_BOOL_ALWAYS_TRUE; goto success; } - unspecialize(instr, to_bool_fail_kind(value)); + reason = to_bool_fail_kind(value); +fail: + unspecialize(instr, reason); return; success: specialize(instr, specialized_op);