This commit is contained in:
blueloveTH 2024-08-05 16:54:48 +08:00
parent 1735e0d3b8
commit 90eb50a3a5

View File

@ -386,12 +386,14 @@ static bool builtins_hasattr(int argc, py_Ref argv) {
PY_CHECK_ARGC(2);
PY_CHECK_ARG_TYPE(1, tp_str);
py_Name name = py_namev(py_tosv(py_arg(1)));
py_StackRef p0 = py_peek(0);
bool ok = py_getattr(py_arg(0), name);
if(ok) {
py_newbool(py_retval(), true);
return true;
}
if(py_matchexc(tp_AttributeError)) {
py_clearexc(p0);
py_newbool(py_retval(), false);
return true;
}