Skip to content

Commit 682f9e6

Browse files
committed
vm: Make sure that exception triple is <type, instance, traceback>.
This reduntant triple is one of the ugliest parts of Python, which they chickened out to fix in Python3. We really should consider passing just as single exception instance (without breaking Python-level APIs of course), but until we do, let's follow CPython layout.
1 parent 4fff26a commit 682f9e6

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

py/vm.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,8 +415,8 @@ mp_vm_return_kind_t mp_execute_byte_code_2(const byte *code_info, const byte **i
415415
// if TOS is None, just pops it and continues
416416
// if TOS is an integer, does something else
417417
// else error
418-
if (mp_obj_is_exception_instance(TOP())) {
419-
nlr_jump(TOP());
418+
if (mp_obj_is_exception_type(TOP())) {
419+
nlr_jump(sp[-1]);
420420
}
421421
if (TOP() == mp_const_none) {
422422
sp--;
@@ -716,7 +716,7 @@ mp_vm_return_kind_t mp_execute_byte_code_2(const byte *code_info, const byte **i
716716
// push(traceback, exc-val, exc-type)
717717
PUSH(mp_const_none);
718718
PUSH(nlr.ret_val);
719-
PUSH(nlr.ret_val); // TODO should be type(nlr.ret_val), I think...
719+
PUSH(mp_obj_get_type(nlr.ret_val));
720720

721721
} else {
722722
// propagate exception to higher level

0 commit comments

Comments
 (0)