diff -r a5acd7ca8727 Lib/test/test_super.py --- a/Lib/test/test_super.py Tue Apr 12 07:52:22 2016 +0200 +++ b/Lib/test/test_super.py Tue Apr 12 21:45:42 2016 +0300 @@ -171,6 +171,15 @@ class TestSuper(unittest.TestCase): c = f().__closure__[0] 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__": unittest.main() diff -r a5acd7ca8727 Objects/typeobject.c --- a/Objects/typeobject.c Tue Apr 12 07:52:22 2016 +0200 +++ b/Objects/typeobject.c Tue Apr 12 21:45:42 2016 +0300 @@ -7350,9 +7350,9 @@ super_init(PyObject *self, PyObject *arg Py_INCREF(obj); } Py_INCREF(type); - su->type = type; - su->obj = obj; - su->obj_type = obj_type; + Py_XSETREF(su->type, type); + Py_XSETREF(su->obj, obj); + Py_XSETREF(su->obj_type, obj_type); return 0; }