mirror of https://github.com/python/cpython.git
gh-91632: Fix generic_alias_iterator to be finalized at exit. (GH-91727)
This commit is contained in:
parent
f92bcfe6de
commit
f571c26fc1
|
@ -0,0 +1 @@
|
||||||
|
Fix a minor memory leak at exit: release the memory of the :class:`generic_alias_iterator` type. Patch by Dong-hee Na.
|
|
@ -683,7 +683,9 @@ ga_iter_clear(PyObject *self) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyTypeObject Py_GenericAliasIterType = {
|
// gh-91632: _Py_GenericAliasIterType is exported to be cleared
|
||||||
|
// in _PyTypes_FiniTypes.
|
||||||
|
PyTypeObject _Py_GenericAliasIterType = {
|
||||||
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
||||||
.tp_name = "generic_alias_iterator",
|
.tp_name = "generic_alias_iterator",
|
||||||
.tp_basicsize = sizeof(gaiterobject),
|
.tp_basicsize = sizeof(gaiterobject),
|
||||||
|
@ -697,7 +699,7 @@ static PyTypeObject Py_GenericAliasIterType = {
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
ga_iter(PyObject *self) {
|
ga_iter(PyObject *self) {
|
||||||
gaiterobject *gi = PyObject_GC_New(gaiterobject, &Py_GenericAliasIterType);
|
gaiterobject *gi = PyObject_GC_New(gaiterobject, &_Py_GenericAliasIterType);
|
||||||
if (gi == NULL) {
|
if (gi == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1834,6 +1834,7 @@ _PyTypes_InitState(PyInterpreterState *interp)
|
||||||
#ifdef MS_WINDOWS
|
#ifdef MS_WINDOWS
|
||||||
extern PyTypeObject PyHKEY_Type;
|
extern PyTypeObject PyHKEY_Type;
|
||||||
#endif
|
#endif
|
||||||
|
extern PyTypeObject _Py_GenericAliasIterType;
|
||||||
|
|
||||||
static PyTypeObject* static_types[] = {
|
static PyTypeObject* static_types[] = {
|
||||||
// The two most important base types: must be initialized first and
|
// The two most important base types: must be initialized first and
|
||||||
|
@ -1923,6 +1924,7 @@ static PyTypeObject* static_types[] = {
|
||||||
&_PyAsyncGenWrappedValue_Type,
|
&_PyAsyncGenWrappedValue_Type,
|
||||||
&_PyContextTokenMissing_Type,
|
&_PyContextTokenMissing_Type,
|
||||||
&_PyCoroWrapper_Type,
|
&_PyCoroWrapper_Type,
|
||||||
|
&_Py_GenericAliasIterType,
|
||||||
&_PyHamtItems_Type,
|
&_PyHamtItems_Type,
|
||||||
&_PyHamtKeys_Type,
|
&_PyHamtKeys_Type,
|
||||||
&_PyHamtValues_Type,
|
&_PyHamtValues_Type,
|
||||||
|
|
Loading…
Reference in New Issue