This commit is contained in:
blueloveTH 2024-01-02 21:25:24 +08:00
parent f9cc6d602e
commit e2f36d017b
4 changed files with 15 additions and 8 deletions

View File

@ -856,11 +856,9 @@ __NEXT_STEP:;
#undef CEVAL_STEP
/**********************************************************************/
UNREACHABLE();
}catch(HandledException& e){
PK_UNUSED(e);
}catch(HandledException){
continue;
}catch(UnhandledException& e){
PK_UNUSED(e);
}catch(UnhandledException){
PyObject* e_obj = POPX();
Exception& _e = PK_OBJ_GET(Exception, e_obj);
_pop_frame();
@ -874,8 +872,7 @@ __NEXT_STEP:;
PUSH(e_obj);
if(frame.index < base_id) throw ToBeRaisedException();
need_raise = true;
}catch(ToBeRaisedException& e){
PK_UNUSED(e);
}catch(ToBeRaisedException){
need_raise = true;
}
}

View File

@ -30,7 +30,7 @@ namespace pkpy {
try{
vm->exec(line, "<stdin>", mode);
}catch(NeedMoreLines& ne){
}catch(NeedMoreLines ne){
buffer += line;
buffer += '\n';
need_more_lines = ne.is_compiling_class ? 3 : 2;

View File

@ -178,6 +178,9 @@ namespace pkpy{
msg = msg + e.what() + "\n";
_stderr(msg.data, msg.size);
}
catch(NeedMoreLines){
throw;
}
catch(...) {
Str msg = "An unknown exception occurred! It could be a bug. Please report it to @blueloveTH on GitHub.\n";
_stderr(msg.data, msg.size);

View File

@ -113,5 +113,12 @@ except MyException as e:
ok = True
except Exception:
exit(1)
assert ok
ok = False
try:
eval('1+')
except SyntaxError as e:
assert type(e) is SyntaxError
ok = True
assert ok