Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert "revert BEFORE_WITH"
This reverts commit 2ee6241.
  • Loading branch information
iritkatriel committed Jan 31, 2023
commit 0a5f78dda13878be08d1eef08a83343c7896142d
18 changes: 7 additions & 11 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);
}

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

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

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