mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
...
This commit is contained in:
parent
1a8877f28a
commit
5d8267977c
@ -62,7 +62,7 @@ struct Exception {
|
||||
stack<ExceptionLine> stacktrace;
|
||||
Exception(StrName type): type(type), is_re(true), _ip_on_error(-1), _code_on_error(nullptr), _self(nullptr) {}
|
||||
|
||||
PyObject* self(){
|
||||
PyObject* self() const{
|
||||
PK_ASSERT(_self != nullptr);
|
||||
return _self;
|
||||
}
|
||||
|
@ -496,11 +496,14 @@ bool pkpy_py_str(pkpy_vm* vm_handle) {
|
||||
bool pkpy_error(pkpy_vm* vm_handle, const char* name, pkpy_CString message) {
|
||||
VM* vm = (VM*) vm_handle;
|
||||
PK_ASSERT_NO_ERROR()
|
||||
PyObject* e_t = vm->builtins->attr().try_get_likely_found(name);
|
||||
PyObject* e_t = vm->_main->attr().try_get_likely_found(name);
|
||||
if(e_t == nullptr){
|
||||
e_t = vm->builtins->attr().try_get_likely_found(name);
|
||||
if(e_t == nullptr){
|
||||
e_t = vm->_t(vm->tp_exception);
|
||||
std::cerr << "[warning] pkpy_error(): " << Str(name).escape() << " not found, fallback to 'Exception'" << std::endl;
|
||||
}
|
||||
}
|
||||
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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user