Skip to content

Commit

Permalink
PUSH_EXC_INFO
Browse files Browse the repository at this point in the history
  • Loading branch information
iritkatriel committed Feb 1, 2023
1 parent 121bc55 commit a052d10
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
16 changes: 6 additions & 10 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -2349,21 +2349,17 @@ dummy_func(
}

// stack effect: ( -- __0)
inst(PUSH_EXC_INFO) {
PyObject *value = TOP();

inst(PUSH_EXC_INFO, (new_exc -- prev_exc, new_exc)) {
_PyErr_StackItem *exc_info = tstate->exc_info;
if (exc_info->exc_value != NULL) {
SET_TOP(exc_info->exc_value);
prev_exc = exc_info->exc_value;
}
else {
SET_TOP(Py_NewRef(Py_None));
prev_exc = Py_NewRef(Py_None);
}

PUSH(Py_NewRef(value));
assert(PyExceptionInstance_Check(value));
exc_info->exc_value = value;

assert(PyExceptionInstance_Check(new_exc));
Py_INCREF(new_exc);
exc_info->exc_value = new_exc;
}

// error: LOAD_ATTR has irregular stack effect
Expand Down
18 changes: 10 additions & 8 deletions Python/generated_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Python/opcode_metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ _PyOpcode_num_popped(int opcode, int oparg) {
case WITH_EXCEPT_START:
return 4;
case PUSH_EXC_INFO:
return -1;
return 1;
case LOAD_ATTR_METHOD_WITH_VALUES:
return -1;
case LOAD_ATTR_METHOD_NO_DICT:
Expand Down Expand Up @@ -623,7 +623,7 @@ _PyOpcode_num_pushed(int opcode, int oparg) {
case WITH_EXCEPT_START:
return 5;
case PUSH_EXC_INFO:
return -1;
return 2;
case LOAD_ATTR_METHOD_WITH_VALUES:
return -1;
case LOAD_ATTR_METHOD_NO_DICT:
Expand Down

0 comments on commit a052d10

Please sign in to comment.