mirror of
https://github.com/pocketpy/pocketpy
synced 2026-02-04 06:30:17 +00:00
fix #440
This commit is contained in:
parent
7b733cae0a
commit
1b2ad4cf2a
@ -1143,19 +1143,24 @@ __NEXT_STEP:
|
|||||||
}
|
}
|
||||||
case OP_EXCEPTION_MATCH: {
|
case OP_EXCEPTION_MATCH: {
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
if(TOP()->type == tp_tuple) {
|
if(TOP()->type == tp_type) {
|
||||||
|
ok = py_isinstance(&self->unhandled_exc, py_totype(TOP()));
|
||||||
|
} else if(TOP()->type == tp_tuple) {
|
||||||
int len = py_tuple_len(TOP());
|
int len = py_tuple_len(TOP());
|
||||||
py_ObjectRef data = py_tuple_data(TOP());
|
py_ObjectRef data = py_tuple_data(TOP());
|
||||||
for(int i = 0; i < len; i++) {
|
for(int i = 0; i < len; i++) {
|
||||||
if(!py_checktype(data + i, tp_type)) goto __ERROR;
|
if(data[i].type != tp_type) {
|
||||||
if(py_isinstance(&self->unhandled_exc, py_totype(data + i))) {
|
py_clearexc(TOP());
|
||||||
ok = true;
|
TypeError(
|
||||||
|
"catching classes that do not inherit from BaseException is not allowed");
|
||||||
|
ok = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
ok = py_isinstance(data + i, py_totype(TOP()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(!py_checktype(TOP(), tp_type)) goto __ERROR;
|
py_clearexc(TOP());
|
||||||
ok = py_isinstance(&self->unhandled_exc, py_totype(TOP()));
|
TypeError("catching classes that do not inherit from BaseException is not allowed");
|
||||||
}
|
}
|
||||||
py_newbool(TOP(), ok);
|
py_newbool(TOP(), ok);
|
||||||
DISPATCH();
|
DISPATCH();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user