From 0f6158e5d025ba46b95c85c6ba0fc24039c3a5f4 Mon Sep 17 00:00:00 2001 From: Peter Bierma Date: Wed, 28 Aug 2024 20:06:45 -0400 Subject: [PATCH 1/2] Move NoDefaultType to the static types array. --- Modules/_typingmodule.c | 3 --- Objects/object.c | 1 + 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Modules/_typingmodule.c b/Modules/_typingmodule.c index 37af00f3071e1d..09fbb3c5e8b91d 100644 --- a/Modules/_typingmodule.c +++ b/Modules/_typingmodule.c @@ -63,9 +63,6 @@ _typing_exec(PyObject *m) if (PyModule_AddObjectRef(m, "TypeAliasType", (PyObject *)&_PyTypeAlias_Type) < 0) { return -1; } - if (PyType_Ready(&_PyNoDefault_Type) < 0) { - return -1; - } if (PyModule_AddObjectRef(m, "NoDefault", (PyObject *)&_Py_NoDefaultStruct) < 0) { return -1; } diff --git a/Objects/object.c b/Objects/object.c index 97403227625971..4b8b6c29266812 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -2347,6 +2347,7 @@ static PyTypeObject* static_types[] = { &_PyWeakref_ProxyType, &_PyWeakref_RefType, &_PyTypeAlias_Type, + &_PyNoDefault_Type, // subclasses: _PyTypes_FiniTypes() deallocates them before their base // class From 42dc3040091169154ca5d10e0cd9afc8370b82c8 Mon Sep 17 00:00:00 2001 From: Peter Bierma Date: Wed, 28 Aug 2024 20:08:54 -0400 Subject: [PATCH 2/2] Add NEWS entry. --- .../next/Library/2024-08-28-20-08-19.gh-issue-123448.tItJlp.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2024-08-28-20-08-19.gh-issue-123448.tItJlp.rst diff --git a/Misc/NEWS.d/next/Library/2024-08-28-20-08-19.gh-issue-123448.tItJlp.rst b/Misc/NEWS.d/next/Library/2024-08-28-20-08-19.gh-issue-123448.tItJlp.rst new file mode 100644 index 00000000000000..a57c133d43545f --- /dev/null +++ b/Misc/NEWS.d/next/Library/2024-08-28-20-08-19.gh-issue-123448.tItJlp.rst @@ -0,0 +1,2 @@ +Fixed memory leak of :class:`typing.NoDefault` by moving it to the static types +array.