Skip to content

Commit 90c363d

Browse files
committed
RERAISE
1 parent b91b42d commit 90c363d

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

Python/bytecodes.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -739,10 +739,10 @@ dummy_func(
739739
Py_XSETREF(exc_info->exc_value, exc_value);
740740
}
741741

742-
// stack effect: (__0 -- )
743-
inst(RERAISE) {
742+
inst(RERAISE, (values[oparg], exc -- values[oparg])) {
743+
assert(oparg >= 0 && oparg <= 2);
744744
if (oparg) {
745-
PyObject *lasti = PEEK(oparg + 1);
745+
PyObject *lasti = values[0];
746746
if (PyLong_Check(lasti)) {
747747
frame->prev_instr = _PyCode_CODE(frame->f_code) + PyLong_AsLong(lasti);
748748
assert(!_PyErr_Occurred(tstate));
@@ -753,11 +753,11 @@ dummy_func(
753753
goto error;
754754
}
755755
}
756-
PyObject *val = POP();
757-
assert(val && PyExceptionInstance_Check(val));
758-
PyObject *exc = Py_NewRef(PyExceptionInstance_Class(val));
759-
PyObject *tb = PyException_GetTraceback(val);
760-
_PyErr_Restore(tstate, exc, val, tb);
756+
assert(exc && PyExceptionInstance_Check(exc));
757+
Py_INCREF(exc);
758+
PyObject *typ = Py_NewRef(PyExceptionInstance_Class(exc));
759+
PyObject *tb = PyException_GetTraceback(exc);
760+
_PyErr_Restore(tstate, typ, exc, tb);
761761
goto exception_unwind;
762762
}
763763

Python/generated_cases.c.h

Lines changed: 10 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/opcode_metadata.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ _PyOpcode_num_popped(int opcode, int oparg, bool jump) {
105105
case POP_EXCEPT:
106106
return 1;
107107
case RERAISE:
108-
return -1;
108+
return oparg + 1;
109109
case PREP_RERAISE_STAR:
110110
return 2;
111111
case END_ASYNC_FOR:
@@ -451,7 +451,7 @@ _PyOpcode_num_pushed(int opcode, int oparg, bool jump) {
451451
case POP_EXCEPT:
452452
return 0;
453453
case RERAISE:
454-
return -1;
454+
return oparg;
455455
case PREP_RERAISE_STAR:
456456
return 1;
457457
case END_ASYNC_FOR:

0 commit comments

Comments
 (0)