This commit is contained in:
blueloveTH 2024-01-02 20:41:54 +08:00
parent 5d8267977c
commit f7c1c956f4
4 changed files with 1 additions and 4 deletions

View File

@ -1202,7 +1202,6 @@ __EAT_DOTS_END:
PyObject* e_obj = vm->call(vm->builtins->attr(type), VAR(msg)); PyObject* e_obj = vm->call(vm->builtins->attr(type), VAR(msg));
Exception& e = PK_OBJ_GET(Exception, e_obj); Exception& e = PK_OBJ_GET(Exception, e_obj);
e.st_push(src, lineno, cursor, ""); e.st_push(src, lineno, cursor, "");
e._self = e_obj;
throw e; throw e;
} }
} // namespace pkpy } // namespace pkpy

View File

@ -1301,6 +1301,7 @@ void init_builtins(VM* _vm) {
StrName cls_name = obj_type_name(vm, cls); StrName cls_name = obj_type_name(vm, cls);
PyObject* e_obj = vm->heap.gcnew<Exception>(cls, cls_name); PyObject* e_obj = vm->heap.gcnew<Exception>(cls, cls_name);
e_obj->_enable_instance_dict(); e_obj->_enable_instance_dict();
PK_OBJ_GET(Exception, e_obj)._self = e_obj;
return e_obj; return e_obj;
}); });

View File

@ -50,7 +50,6 @@ static PyObject* stack_item(VM* vm, int index){
} catch(const std::exception& re){ \ } catch(const std::exception& re){ \
PyObject* e_t = vm->_t(vm->tp_exception); \ PyObject* e_t = vm->_t(vm->tp_exception); \
vm->_c.error = vm->call(e_t, VAR(re.what())); \ vm->_c.error = vm->call(e_t, VAR(re.what())); \
PK_OBJ_GET(Exception, vm->_c.error)._self = vm->_c.error; \
return false; \ return false; \
} }
@ -505,7 +504,6 @@ bool pkpy_error(pkpy_vm* vm_handle, const char* name, pkpy_CString message) {
} }
} }
vm->_c.error = vm->call(e_t, VAR(std::string_view(message.data, message.size))); vm->_c.error = vm->call(e_t, VAR(std::string_view(message.data, message.size)));
PK_OBJ_GET(Exception, vm->_c.error)._self = vm->_c.error;
return false; return false;
} }

View File

@ -1176,7 +1176,6 @@ void VM::_builtin_error(StrName type, const Str& msg){ _builtin_error(type, VAR(
void VM::_error(PyObject* e_obj){ void VM::_error(PyObject* e_obj){
PK_ASSERT(isinstance(e_obj, tp_exception)) PK_ASSERT(isinstance(e_obj, tp_exception))
Exception& e = PK_OBJ_GET(Exception, e_obj); Exception& e = PK_OBJ_GET(Exception, e_obj);
e._self = e_obj;
if(callstack.empty()){ if(callstack.empty()){
e.is_re = false; e.is_re = false;
throw e; throw e;