Skip to content

Commit

Permalink
revert BEFORE_WITH
Browse files Browse the repository at this point in the history
  • Loading branch information
iritkatriel committed Jan 31, 2023
1 parent 6bfec26 commit 2ee6241
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
18 changes: 11 additions & 7 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -2302,10 +2302,10 @@ dummy_func(
PREDICT(GET_AWAITABLE);
}

inst(BEFORE_WITH, (mgr -- exit, res)) {
/* pop the context manager, push its __exit__ and the
* value returned from calling its __enter__
*/
// stack effect: ( -- __0)
inst(BEFORE_WITH) {
PyObject *mgr = TOP();
PyObject *res;
PyObject *enter = _PyObject_LookupSpecial(mgr, &_Py_ID(__enter__));
if (enter == NULL) {
if (!_PyErr_Occurred(tstate)) {
Expand All @@ -2316,7 +2316,7 @@ dummy_func(
}
goto error;
}
exit = _PyObject_LookupSpecial(mgr, &_Py_ID(__exit__));
PyObject *exit = _PyObject_LookupSpecial(mgr, &_Py_ID(__exit__));
if (exit == NULL) {
if (!_PyErr_Occurred(tstate)) {
_PyErr_Format(tstate, PyExc_TypeError,
Expand All @@ -2328,10 +2328,14 @@ dummy_func(
Py_DECREF(enter);
goto error;
}
DECREF_INPUTS();
SET_TOP(exit);
Py_DECREF(mgr);
res = _PyObject_CallNoArgs(enter);
Py_DECREF(enter);
ERROR_IF(res == NULL, error);
if (res == NULL) {
goto error;
}
PUSH(res);
}

inst(WITH_EXCEPT_START, (exit_func, lasti, unused, val -- exit_func, lasti, unused, val, res)) {
Expand Down
17 changes: 7 additions & 10 deletions Python/generated_cases.c.h

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

0 comments on commit 2ee6241

Please sign in to comment.