add p0 assert

This commit is contained in:
blueloveTH 2025-08-31 18:29:19 +08:00
parent 1ab175006d
commit fb93b2bc8b

View File

@ -158,12 +158,14 @@ bool py_matchexc(py_Type type) {
void py_clearexc(py_StackRef p0) {
VM* vm = pk_current_vm;
py_newnil(&vm->unhandled_exc);
if(p0) vm->stack.sp = p0;
if(p0) {
c11__rtassert(p0 >= vm->stack.begin && p0 <= vm->stack.sp);
vm->stack.sp = p0;
}
}
static void c11_sbuf__write_exc(c11_sbuf* self, py_Ref exc) {
if(true) { c11_sbuf__write_cstr(self, "Traceback (most recent call last):\n"); }
c11_sbuf__write_cstr(self, "Traceback (most recent call last):\n");
BaseException* ud = py_touserdata(exc);
for(int i = ud->stacktrace.length - 1; i >= 0; i--) {