summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2021-07-04-23-38-51.bpo-44562.QdeRQo.rst2
-rw-r--r--Objects/genericaliasobject.c6
2 files changed, 5 insertions, 3 deletions
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
new file mode 100644
index 0000000..2fc65bc
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2021-07-04-23-38-51.bpo-44562.QdeRQo.rst
@@ -0,0 +1,2 @@
+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 945d205..bb5fa09 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)) {
- type->tp_free((PyObject *)self);
+ Py_DECREF(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)) {
- PyObject_GC_Del((PyObject *)alias);
+ Py_DECREF(alias);
return NULL;
}
- _PyObject_GC_TRACK(alias);
return (PyObject *)alias;
}