Revert "bpo-44562: Remove invalid PyObject_GC_Del from error path of types.GenericAlias … (GH-27016) (GH-27018)" (GH-27022)

This reverts commit 4684a34c8d.
This commit is contained in:
Pablo Galindo 2021-07-04 20:26:34 +01:00 committed by GitHub
parent 4684a34c8d
commit fe847a6285
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 5 deletions

View file

@ -1,2 +0,0 @@
Remove uses of :c:func:`PyObject_GC_Del` in error path when initializing
:class:`types.GenericAlias`.

View file

@ -602,7 +602,7 @@ ga_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return NULL; return NULL;
} }
if (!setup_ga(self, origin, arguments)) { if (!setup_ga(self, origin, arguments)) {
Py_DECREF(self); type->tp_free((PyObject *)self);
return NULL; return NULL;
} }
return (PyObject *)self; return (PyObject *)self;
@ -644,10 +644,10 @@ Py_GenericAlias(PyObject *origin, PyObject *args)
if (alias == NULL) { if (alias == NULL) {
return NULL; return NULL;
} }
_PyObject_GC_TRACK(alias);
if (!setup_ga(alias, origin, args)) { if (!setup_ga(alias, origin, args)) {
Py_DECREF(alias); PyObject_GC_Del((PyObject *)alias);
return NULL; return NULL;
} }
_PyObject_GC_TRACK(alias);
return (PyObject *)alias; return (PyObject *)alias;
} }