From: Guido van Rossum Date: Sat, 30 Dec 2023 05:06:32 +0000 (-0800) Subject: [3.11] gh-113566: Fix asyncio segfault during interpreter finalization (#113578) X-Git-Tag: v3.11.8~205 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8938495120612122e3519f002104a8322bd864ff;p=thirdparty%2FPython%2Fcpython.git [3.11] gh-113566: Fix asyncio segfault during interpreter finalization (#113578) --- diff --git a/Misc/NEWS.d/next/Core and Builtins/2023-12-29-16-55-12.gh-issue-113566.grGQEg.rst b/Misc/NEWS.d/next/Core and Builtins/2023-12-29-16-55-12.gh-issue-113566.grGQEg.rst new file mode 100644 index 000000000000..7c22afad4469 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2023-12-29-16-55-12.gh-issue-113566.grGQEg.rst @@ -0,0 +1,2 @@ +Fix a 3.11-specific crash when the ``repr`` of a :class:`~asyncio.Future` is +requested after the module has already been garbage-collected. diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c index b2fef017050b..a92feebcdbc4 100644 --- a/Modules/_asynciomodule.c +++ b/Modules/_asynciomodule.c @@ -1377,6 +1377,9 @@ static PyObject * FutureObj_repr(FutureObj *fut) { ENSURE_FUTURE_ALIVE(fut) + if (asyncio_future_repr_func == NULL) { + return PyUnicode_FromFormat("", fut); + } return PyObject_CallOneArg(asyncio_future_repr_func, (PyObject *)fut); }