From 4587ad7bf5e2e5037f8961b88f14fdba0ccb63c6 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Fri, 29 Dec 2023 16:50:41 -0800 Subject: [PATCH 1/2] Fix crash in FutureObj_repr during finalization --- Modules/_asynciomodule.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c index b2fef017050b22..a92feebcdbc4ac 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); } From 3319668d221579ce2974167e863c8542069403e3 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Fri, 29 Dec 2023 16:55:22 -0800 Subject: [PATCH 2/2] Blurb --- .../2023-12-29-16-55-12.gh-issue-113566.grGQEg.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2023-12-29-16-55-12.gh-issue-113566.grGQEg.rst 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 00000000000000..7c22afad446990 --- /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.