[Python-3000-checkins] r58993 - python/branches/py3k/Objects/object.c python/branches/py3k/Objects/rangeobject.c
amaury.forgeotdarc
python-3000-checkins at python.org
Thu Nov 15 21:52:22 CET 2007
Author: amaury.forgeotdarc
Date: Thu Nov 15 21:52:21 2007
New Revision: 58993
Modified:
python/branches/py3k/Objects/object.c
python/branches/py3k/Objects/rangeobject.c
Log:
Found another memory leak in longrangeiter. And redo the previous correction
without calling PyType_Ready().
Question 1: Should the interpreter register all types with PyType_Ready()?
Many types seem to avoid it.
Question 2: To reproduce the problem, run the following code:
def f():
while True:
for a in iter(range(0,1,10**20)):
pass
f()
And watch the memory used by the process.
How do we test this in a unittest?
Modified: python/branches/py3k/Objects/object.c
==============================================================================
--- python/branches/py3k/Objects/object.c (original)
+++ python/branches/py3k/Objects/object.c Thu Nov 15 21:52:21 2007
@@ -1509,9 +1509,6 @@
if (PyType_Ready(&PyStdPrinter_Type) < 0)
Py_FatalError("Can't initialize StdPrinter");
-
- if (PyType_Ready(&PyRange_Type) < 0)
- Py_FatalError("Can't initialize 'range'");
}
Modified: python/branches/py3k/Objects/rangeobject.c
==============================================================================
--- python/branches/py3k/Objects/rangeobject.c (original)
+++ python/branches/py3k/Objects/rangeobject.c Thu Nov 15 21:52:21 2007
@@ -107,7 +107,7 @@
Py_DECREF(r->start);
Py_DECREF(r->stop);
Py_DECREF(r->step);
- Py_Type(r)->tp_free(r);
+ PyObject_Del(r);
}
/* Return number of items in range (lo, hi, step), when arguments are
@@ -482,6 +482,7 @@
Py_XDECREF(r->start);
Py_XDECREF(r->step);
Py_XDECREF(r->len);
+ PyObject_Del(r);
}
static PyObject *
More information about the Python-3000-checkins
mailing list