mirror of
https://github.com/AdaCore/cpython.git
synced 2026-02-12 12:57:15 -08:00
bpo-39048: Look up __aenter__ before __aexit__ in async with (GH-17609)
* Reorder the __aenter__ and __aexit__ checks for async with * Add assertions for async with body being skipped * Swap __aexit__ and __aenter__ loading in the documentation
This commit is contained in:
@@ -3230,20 +3230,21 @@ main_loop:
|
||||
}
|
||||
|
||||
case TARGET(BEFORE_ASYNC_WITH): {
|
||||
_Py_IDENTIFIER(__aexit__);
|
||||
_Py_IDENTIFIER(__aenter__);
|
||||
|
||||
_Py_IDENTIFIER(__aexit__);
|
||||
PyObject *mgr = TOP();
|
||||
PyObject *exit = special_lookup(tstate, mgr, &PyId___aexit__),
|
||||
*enter;
|
||||
PyObject *enter = special_lookup(tstate, mgr, &PyId___aenter__);
|
||||
PyObject *res;
|
||||
if (exit == NULL)
|
||||
if (enter == NULL) {
|
||||
goto error;
|
||||
}
|
||||
PyObject *exit = special_lookup(tstate, mgr, &PyId___aexit__);
|
||||
if (exit == NULL) {
|
||||
Py_DECREF(enter);
|
||||
goto error;
|
||||
}
|
||||
SET_TOP(exit);
|
||||
enter = special_lookup(tstate, mgr, &PyId___aenter__);
|
||||
Py_DECREF(mgr);
|
||||
if (enter == NULL)
|
||||
goto error;
|
||||
res = _PyObject_CallNoArg(enter);
|
||||
Py_DECREF(enter);
|
||||
if (res == NULL)
|
||||
@@ -3264,8 +3265,8 @@ main_loop:
|
||||
}
|
||||
|
||||
case TARGET(SETUP_WITH): {
|
||||
_Py_IDENTIFIER(__exit__);
|
||||
_Py_IDENTIFIER(__enter__);
|
||||
_Py_IDENTIFIER(__exit__);
|
||||
PyObject *mgr = TOP();
|
||||
PyObject *enter = special_lookup(tstate, mgr, &PyId___enter__);
|
||||
PyObject *res;
|
||||
|
||||
Reference in New Issue
Block a user