From fe847a62852c3baaec6c97a5e2e7b2e66732bdb8 Mon Sep 17 00:00:00 2001 From: Pablo Galindo Date: Sun, 4 Jul 2021 20:26:34 +0100 Subject: [PATCH] =?UTF-8?q?Revert=20"bpo-44562:=20Remove=20invalid=20PyObj?= =?UTF-8?q?ect=5FGC=5FDel=20from=20error=20path=20of=20types.GenericAlias?= =?UTF-8?q?=20=E2=80=A6=20(GH-27016)=20(GH-27018)"=20(GH-27022)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 4684a34c8d2a2ffac7b779edb4ba57f043783478. --- .../2021-07-04-23-38-51.bpo-44562.QdeRQo.rst | 2 -- Objects/genericaliasobject.c | 6 +++--- 2 files changed, 3 insertions(+), 5 deletions(-) delete mode 100644 Misc/NEWS.d/next/Core and Builtins/2021-07-04-23-38-51.bpo-44562.QdeRQo.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2021-07-04-23-38-51.bpo-44562.QdeRQo.rst b/Misc/NEWS.d/next/Core and Builtins/2021-07-04-23-38-51.bpo-44562.QdeRQo.rst deleted file mode 100644 index 2fc65bcfdee..00000000000 --- a/Misc/NEWS.d/next/Core and Builtins/2021-07-04-23-38-51.bpo-44562.QdeRQo.rst +++ /dev/null @@ -1,2 +0,0 @@ -Remove uses of :c:func:`PyObject_GC_Del` in error path when initializing -:class:`types.GenericAlias`. diff --git a/Objects/genericaliasobject.c b/Objects/genericaliasobject.c index bb5fa095d35..945d20593c7 100644 --- a/Objects/genericaliasobject.c +++ b/Objects/genericaliasobject.c @@ -602,7 +602,7 @@ ga_new(PyTypeObject *type, PyObject *args, PyObject *kwds) return NULL; } if (!setup_ga(self, origin, arguments)) { - Py_DECREF(self); + type->tp_free((PyObject *)self); return NULL; } return (PyObject *)self; @@ -644,10 +644,10 @@ Py_GenericAlias(PyObject *origin, PyObject *args) if (alias == NULL) { return NULL; } - _PyObject_GC_TRACK(alias); if (!setup_ga(alias, origin, args)) { - Py_DECREF(alias); + PyObject_GC_Del((PyObject *)alias); return NULL; } + _PyObject_GC_TRACK(alias); return (PyObject *)alias; }