Skip to content

Commit 8938495

Browse files
authored
[3.11] gh-113566: Fix asyncio segfault during interpreter finalization (#113578)
1 parent ced2d35 commit 8938495

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix a 3.11-specific crash when the ``repr`` of a :class:`~asyncio.Future` is
2+
requested after the module has already been garbage-collected.

Modules/_asynciomodule.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,6 +1377,9 @@ static PyObject *
13771377
FutureObj_repr(FutureObj *fut)
13781378
{
13791379
ENSURE_FUTURE_ALIVE(fut)
1380+
if (asyncio_future_repr_func == NULL) {
1381+
return PyUnicode_FromFormat("<Future at %p>", fut);
1382+
}
13801383
return PyObject_CallOneArg(asyncio_future_repr_func, (PyObject *)fut);
13811384
}
13821385

0 commit comments

Comments
 (0)