From d9b10c47f14c77c50dc04adb2fd81a39e814c0a8 Mon Sep 17 00:00:00 2001 From: killcerr Date: Fri, 30 Jan 2026 17:14:11 +0800 Subject: [PATCH] fix #440 --- src/interpreter/ceval.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/interpreter/ceval.c b/src/interpreter/ceval.c index fb16e3c8..78ef3ece 100644 --- a/src/interpreter/ceval.c +++ b/src/interpreter/ceval.c @@ -1142,8 +1142,21 @@ __NEXT_STEP: DISPATCH(); } case OP_EXCEPTION_MATCH: { - if(!py_checktype(TOP(), tp_type)) goto __ERROR; - bool ok = py_isinstance(&self->unhandled_exc, py_totype(TOP())); + bool ok = false; + 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()); + py_ObjectRef data = py_tuple_data(TOP()); + for(int i = 0; i < len; i++) { + if(!py_checktype(data + i, tp_type)) goto __ERROR; + if(py_isinstance(&self->unhandled_exc, py_totype(data + i))) { + ok = true; + break; + } + } + } else + goto __ERROR; py_newbool(TOP(), ok); DISPATCH(); }