Skip to content

Commit d6e9dc6

Browse files
iritkatrielremykarem
authored andcommitted
bpo-45711: Use _PyErr_ClearExcState instead of setting only exc_value to NULL (pythonGH-29404)
1 parent 669fb41 commit d6e9dc6

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Modules/_asynciomodule.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,10 +1371,15 @@ _asyncio_Future__make_cancelled_error_impl(FutureObj *self)
13711371
{
13721372
PyObject *exc = create_cancelled_error(self->fut_cancel_msg);
13731373
_PyErr_StackItem *exc_state = &self->fut_cancelled_exc_state;
1374-
/* Transfer ownership of exc_value from exc_state to exc since we are
1375-
done with it. */
1376-
PyException_SetContext(exc, exc_state->exc_value);
1377-
exc_state->exc_value = NULL;
1374+
1375+
if (exc_state->exc_value) {
1376+
PyException_SetContext(exc, Py_NewRef(exc_state->exc_value));
1377+
_PyErr_ClearExcState(exc_state);
1378+
}
1379+
else {
1380+
assert(exc_state->exc_type == NULL);
1381+
assert(exc_state->exc_traceback == NULL);
1382+
}
13781383

13791384
return exc;
13801385
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy