Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0a5f78d

Browse filesBrowse files
committed
Revert "revert BEFORE_WITH"
This reverts commit 2ee6241.
1 parent 2ee6241 commit 0a5f78d
Copy full SHA for 0a5f78d

File tree

Expand file treeCollapse file tree

2 files changed

+17
-18
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+17
-18
lines changed

‎Python/bytecodes.c

Copy file name to clipboardExpand all lines: Python/bytecodes.c
+7-11Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2302,10 +2302,10 @@ dummy_func(
23022302
PREDICT(GET_AWAITABLE);
23032303
}
23042304

2305-
// stack effect: ( -- __0)
2306-
inst(BEFORE_WITH) {
2307-
PyObject *mgr = TOP();
2308-
PyObject *res;
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+
*/
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-
PyObject *exit = _PyObject_LookupSpecial(mgr, &_Py_ID(__exit__));
2319+
exit = _PyObject_LookupSpecial(mgr, &_Py_ID(__exit__));
23202320
if (exit == NULL) {
23212321
if (!_PyErr_Occurred(tstate)) {
23222322
_PyErr_Format(tstate, PyExc_TypeError,
@@ -2328,14 +2328,10 @@ dummy_func(
23282328
Py_DECREF(enter);
23292329
goto error;
23302330
}
2331-
SET_TOP(exit);
2332-
Py_DECREF(mgr);
2331+
DECREF_INPUTS();
23332332
res = _PyObject_CallNoArgs(enter);
23342333
Py_DECREF(enter);
2335-
if (res == NULL) {
2336-
goto error;
2337-
}
2338-
PUSH(res);
2334+
ERROR_IF(res == NULL, error);
23392335
}
23402336

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

‎Python/generated_cases.c.h

Copy file name to clipboardExpand all lines: Python/generated_cases.c.h
+10-7Lines changed: 10 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.