Skip to content

Commit 2ee6241

Browse files
committed
revert BEFORE_WITH
1 parent 6bfec26 commit 2ee6241

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

Python/bytecodes.c

+11-7
Original file line numberDiff line numberDiff line change
@@ -2302,10 +2302,10 @@ dummy_func(
23022302
PREDICT(GET_AWAITABLE);
23032303
}
23042304

2305-
inst(BEFORE_WITH, (mgr -- exit, res)) {
2306-
/* pop the context manager, push its __exit__ and the
2307-
* value returned from calling its __enter__
2308-
*/
2305+
// stack effect: ( -- __0)
2306+
inst(BEFORE_WITH) {
2307+
PyObject *mgr = TOP();
2308+
PyObject *res;
23092309
PyObject *enter = _PyObject_LookupSpecial(mgr, &_Py_ID(__enter__));
23102310
if (enter == NULL) {
23112311
if (!_PyErr_Occurred(tstate)) {
@@ -2316,7 +2316,7 @@ dummy_func(
23162316
}
23172317
goto error;
23182318
}
2319-
exit = _PyObject_LookupSpecial(mgr, &_Py_ID(__exit__));
2319+
PyObject *exit = _PyObject_LookupSpecial(mgr, &_Py_ID(__exit__));
23202320
if (exit == NULL) {
23212321
if (!_PyErr_Occurred(tstate)) {
23222322
_PyErr_Format(tstate, PyExc_TypeError,
@@ -2328,10 +2328,14 @@ dummy_func(
23282328
Py_DECREF(enter);
23292329
goto error;
23302330
}
2331-
DECREF_INPUTS();
2331+
SET_TOP(exit);
2332+
Py_DECREF(mgr);
23322333
res = _PyObject_CallNoArgs(enter);
23332334
Py_DECREF(enter);
2334-
ERROR_IF(res == NULL, error);
2335+
if (res == NULL) {
2336+
goto error;
2337+
}
2338+
PUSH(res);
23352339
}
23362340

23372341
inst(WITH_EXCEPT_START, (exit_func, lasti, unused, val -- exit_func, lasti, unused, val, res)) {

Python/generated_cases.c.h

+7-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)