blueloveTH 1 year ago
parent
commit
90eb50a3a5
1 changed files with 2 additions and 0 deletions
  1. 2 0
      src/public/modules.c

+ 2 - 0
src/public/modules.c

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