Skip to content

Commit c861af5

Browse files
committed
CLEANUP_THROW
1 parent 90c363d commit c861af5

File tree

3 files changed

+15
-19
lines changed

3 files changed

+15
-19
lines changed

Python/bytecodes.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -784,18 +784,12 @@ dummy_func(
784784
}
785785
}
786786

787-
// stack effect: (__0, __1 -- )
788-
inst(CLEANUP_THROW) {
787+
inst(CLEANUP_THROW, (sub_iter, last_sent_val, exc_value -- value)) {
789788
assert(throwflag);
790-
PyObject *exc_value = TOP();
791789
assert(exc_value && PyExceptionInstance_Check(exc_value));
792790
if (PyErr_GivenExceptionMatches(exc_value, PyExc_StopIteration)) {
793-
PyObject *value = ((PyStopIterationObject *)exc_value)->value;
794-
Py_INCREF(value);
795-
Py_DECREF(POP()); // The StopIteration.
796-
Py_DECREF(POP()); // The last sent value.
797-
Py_DECREF(POP()); // The delegated sub-iterator.
798-
PUSH(value);
791+
value = Py_NewRef(((PyStopIterationObject *)exc_value)->value);
792+
DECREF_INPUTS();
799793
}
800794
else {
801795
PyObject *exc_type = Py_NewRef(Py_TYPE(exc_value));

Python/generated_cases.c.h

Lines changed: 10 additions & 8 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
@@ -111,7 +111,7 @@ _PyOpcode_num_popped(int opcode, int oparg, bool jump) {
111111
case END_ASYNC_FOR:
112112
return 2;
113113
case CLEANUP_THROW:
114-
return -1;
114+
return 3;
115115
case LOAD_ASSERTION_ERROR:
116116
return 0;
117117
case LOAD_BUILD_CLASS:
@@ -457,7 +457,7 @@ _PyOpcode_num_pushed(int opcode, int oparg, bool jump) {
457457
case END_ASYNC_FOR:
458458
return 0;
459459
case CLEANUP_THROW:
460-
return -1;
460+
return 1;
461461
case LOAD_ASSERTION_ERROR:
462462
return 1;
463463
case LOAD_BUILD_CLASS:

0 commit comments

Comments
 (0)