mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
fix a bug
This commit is contained in:
parent
0b7f63ccaf
commit
4a81e975c8
@ -61,10 +61,16 @@ void Frame__delete(py_Frame* self) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int Frame__goto_exception_handler(py_Frame* self, ValueStack* value_stack, py_Ref exc) {
|
int Frame__goto_exception_handler(py_Frame* self, ValueStack* value_stack, py_Ref exc) {
|
||||||
if(self->exc_stack.length == 0) return -1;
|
FrameExcInfo* p = self->exc_stack.data;
|
||||||
FrameExcInfo* info = &c11_vector__back(FrameExcInfo, &self->exc_stack);
|
for(int i = self->exc_stack.length - 1; i >= 0; i--) {
|
||||||
value_stack->sp = (self->p0 + info->offset); // unwind the stack
|
if(py_isnil(&p[i].exc)) {
|
||||||
return c11__at(CodeBlock, &self->co->blocks, info->iblock)->end;
|
value_stack->sp = (self->p0 + p[i].offset); // unwind the stack
|
||||||
|
return c11__at(CodeBlock, &self->co->blocks, p[i].iblock)->end;
|
||||||
|
} else {
|
||||||
|
self->exc_stack.length--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Frame__begin_try(py_Frame* self, py_TValue* sp) {
|
void Frame__begin_try(py_Frame* self, py_TValue* sp) {
|
||||||
|
@ -179,6 +179,17 @@ for i in range(10):
|
|||||||
assert e.args[0] == i
|
assert e.args[0] == i
|
||||||
assert a == list(range(10))
|
assert a == list(range(10))
|
||||||
|
|
||||||
|
# inner exc
|
||||||
|
x = 0
|
||||||
|
try:
|
||||||
|
try:
|
||||||
|
[][1]
|
||||||
|
except:
|
||||||
|
raise KeyError
|
||||||
|
except KeyError:
|
||||||
|
x = 5
|
||||||
|
assert x == 5
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# finally, only
|
# finally, only
|
||||||
def finally_only():
|
def finally_only():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user