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

View File

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

View File

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

View File

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