This commit is contained in:
blueloveTH 2024-07-25 19:55:19 +08:00
parent b6eeaa8cbc
commit 3ea3cf7366
3 changed files with 18 additions and 1 deletions

View File

@ -887,7 +887,7 @@ pk_FrameResult pk_VM__run_top_frame(pk_VM* self) {
goto __ERROR; goto __ERROR;
} }
case OP_RE_RAISE: { case OP_RE_RAISE: {
py_raise(&self->curr_exception); assert(self->curr_exception.type);
goto __ERROR_RE_RAISE; goto __ERROR_RE_RAISE;
} }
case OP_PUSH_EXCEPTION: { case OP_PUSH_EXCEPTION: {

View File

@ -199,6 +199,11 @@ static bool _py_builtins__print(int argc, py_Ref argv) {
return true; return true;
} }
static bool _py_NoneType__repr__(int argc, py_Ref argv) {
py_newstr(py_retval(), "None");
return true;
}
py_TValue pk_builtins__register() { py_TValue pk_builtins__register() {
py_Ref builtins = py_newmodule("builtins", NULL); py_Ref builtins = py_newmodule("builtins", NULL);
py_bindnativefunc(builtins, "repr", _py_builtins__repr); py_bindnativefunc(builtins, "repr", _py_builtins__repr);
@ -214,6 +219,9 @@ py_TValue pk_builtins__register() {
py_bind(builtins, "print(*args, sep=' ', end='\\n')", _py_builtins__print); py_bind(builtins, "print(*args, sep=' ', end='\\n')", _py_builtins__print);
py_bind(builtins, "sorted(iterable, key=None, reverse=False)", _py_builtins__sorted); py_bind(builtins, "sorted(iterable, key=None, reverse=False)", _py_builtins__sorted);
// None __repr__
py_bindmagic(tp_NoneType, __repr__, _py_NoneType__repr__);
return *builtins; return *builtins;
} }

View File

@ -1,3 +1,12 @@
def f():
raise IndexError
try:
f()
exit(1)
except IndexError:
pass
try: try:
assert False assert False
exit(1) exit(1)