Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix memory leak in ``memoryview`` iterator as it was not finalized at exit. Patch by Kumar Aditya.
6 changes: 3 additions & 3 deletions Objects/memoryobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -3156,7 +3156,7 @@ static PyMethodDef memory_methods[] = {
/* Memoryview Iterator */
/**************************************************************************/

static PyTypeObject PyMemoryIter_Type;
PyTypeObject _PyMemoryIter_Type;

typedef struct {
PyObject_HEAD
Expand Down Expand Up @@ -3233,7 +3233,7 @@ memory_iter(PyObject *seq)
}

memoryiterobject *it;
it = PyObject_GC_New(memoryiterobject, &PyMemoryIter_Type);
it = PyObject_GC_New(memoryiterobject, &_PyMemoryIter_Type);
if (it == NULL) {
return NULL;
}
Expand All @@ -3246,7 +3246,7 @@ memory_iter(PyObject *seq)
return (PyObject *)it;
}

static PyTypeObject PyMemoryIter_Type = {
PyTypeObject _PyMemoryIter_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
.tp_name = "memory_iterator",
.tp_basicsize = sizeof(memoryiterobject),
Expand Down
2 changes: 2 additions & 0 deletions Objects/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -1845,6 +1845,7 @@ _PyTypes_InitState(PyInterpreterState *interp)
extern PyTypeObject PyHKEY_Type;
#endif
extern PyTypeObject _Py_GenericAliasIterType;
extern PyTypeObject _PyMemoryIter_Type;

static PyTypeObject* static_types[] = {
// The two most important base types: must be initialized first and
Expand Down Expand Up @@ -1944,6 +1945,7 @@ static PyTypeObject* static_types[] = {
&_PyHamt_Type,
&_PyInterpreterID_Type,
&_PyManagedBuffer_Type,
&_PyMemoryIter_Type,
&_PyMethodWrapper_Type,
&_PyNamespace_Type,
&_PyNone_Type,
Expand Down