From 51ab01125338270e9a60cb9c152feb634e3c8040 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 7 Sep 2023 00:04:19 +0800 Subject: [PATCH] change `AttributeError`'s error msg --- include/pocketpy/vm.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/pocketpy/vm.h b/include/pocketpy/vm.h index 6b28523a..e37eedb4 100644 --- a/include/pocketpy/vm.h +++ b/include/pocketpy/vm.h @@ -372,7 +372,11 @@ public: void AttributeError(PyObject* obj, StrName name){ // OBJ_NAME calls getattr, which may lead to a infinite recursion - _error("AttributeError", fmt("type ", OBJ_NAME(_t(obj)).escape(), " has no attribute ", name.escape())); + if(isinstance(obj, vm->tp_type)){ + _error("AttributeError", fmt("type object ", OBJ_NAME(obj).escape(), " has no attribute ", name.escape())); + }else{ + _error("AttributeError", fmt(OBJ_NAME(_t(obj)).escape(), " object has no attribute ", name.escape())); + } } void AttributeError(Str msg){ _error("AttributeError", msg); }