mirror of https://github.com/python/cpython
Issue #26718: super.__init__ no longer leaks memory if called multiple times.
NOTE: A direct call of super.__init__ is not endorsed!
This commit is contained in:
parent
a3c532b0ed
commit
3d7497608b
|
@ -171,6 +171,15 @@ class TestSuper(unittest.TestCase):
|
||||||
c = f().__closure__[0]
|
c = f().__closure__[0]
|
||||||
self.assertRaises(TypeError, X.meth, c)
|
self.assertRaises(TypeError, X.meth, c)
|
||||||
|
|
||||||
|
def test_super_init_leaks(self):
|
||||||
|
# Issue #26718: super.__init__ leaked memory if called multiple times.
|
||||||
|
# This will be caught by regrtest.py -R if this leak.
|
||||||
|
# NOTE: Despite the use in the test a direct call of super.__init__
|
||||||
|
# is not endorsed.
|
||||||
|
sp = super(float, 1.0)
|
||||||
|
for i in range(1000):
|
||||||
|
super.__init__(sp, int, i)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
@ -10,6 +10,9 @@ Release date: tba
|
||||||
Core and Builtins
|
Core and Builtins
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Issue #26718: super.__init__ no longer leaks memory if called multiple times.
|
||||||
|
NOTE: A direct call of super.__init__ is not endorsed!
|
||||||
|
|
||||||
- Issue #25339: PYTHONIOENCODING now has priority over locale in setting the
|
- Issue #25339: PYTHONIOENCODING now has priority over locale in setting the
|
||||||
error handler for stdin and stdout.
|
error handler for stdin and stdout.
|
||||||
|
|
||||||
|
|
|
@ -7336,9 +7336,9 @@ super_init(PyObject *self, PyObject *args, PyObject *kwds)
|
||||||
Py_INCREF(obj);
|
Py_INCREF(obj);
|
||||||
}
|
}
|
||||||
Py_INCREF(type);
|
Py_INCREF(type);
|
||||||
su->type = type;
|
Py_XSETREF(su->type, type);
|
||||||
su->obj = obj;
|
Py_XSETREF(su->obj, obj);
|
||||||
su->obj_type = obj_type;
|
Py_XSETREF(su->obj_type, obj_type);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue