An interpreted, interactive, object-oriented programming language
CentOS Sources
2017-08-01 71084d584ff953f5463757ec6536406320560b4d
SOURCES/00147-add-debug-malloc-stats.patch
@@ -1,7 +1,8 @@
diff -up Python-2.7.2/Include/dictobject.h.add-debug-malloc-stats Python-2.7.2/Include/dictobject.h
--- Python-2.7.2/Include/dictobject.h.add-debug-malloc-stats   2011-06-11 11:46:23.000000000 -0400
+++ Python-2.7.2/Include/dictobject.h   2011-09-16 19:03:25.105821625 -0400
@@ -150,6 +150,8 @@ PyAPI_FUNC(PyObject *) PyDict_GetItemStr
diff --git a/Include/dictobject.h b/Include/dictobject.h
index ece01c6..acc1df0 100644
--- a/Include/dictobject.h
+++ b/Include/dictobject.h
@@ -150,6 +150,8 @@ PyAPI_FUNC(PyObject *) PyDict_GetItemString(PyObject *dp, const char *key);
 PyAPI_FUNC(int) PyDict_SetItemString(PyObject *dp, const char *key, PyObject *item);
 PyAPI_FUNC(int) PyDict_DelItemString(PyObject *dp, const char *key);
 
@@ -10,10 +11,11 @@
 #ifdef __cplusplus
 }
 #endif
diff -up Python-2.7.2/Include/floatobject.h.add-debug-malloc-stats Python-2.7.2/Include/floatobject.h
--- Python-2.7.2/Include/floatobject.h.add-debug-malloc-stats   2011-06-11 11:46:23.000000000 -0400
+++ Python-2.7.2/Include/floatobject.h   2011-09-16 19:03:25.106821625 -0400
@@ -132,6 +132,7 @@ PyAPI_FUNC(PyObject *) _PyFloat_FormatAd
diff --git a/Include/floatobject.h b/Include/floatobject.h
index 54e8825..33c6ac0 100644
--- a/Include/floatobject.h
+++ b/Include/floatobject.h
@@ -132,6 +132,7 @@ PyAPI_FUNC(PyObject *) _PyFloat_FormatAdvanced(PyObject *obj,
    failure.  Used in builtin_round in bltinmodule.c. */
 PyAPI_FUNC(PyObject *) _Py_double_round(double x, int ndigits);
 
@@ -21,10 +23,11 @@
 
 
 #ifdef __cplusplus
diff -up Python-2.7.2/Include/frameobject.h.add-debug-malloc-stats Python-2.7.2/Include/frameobject.h
--- Python-2.7.2/Include/frameobject.h.add-debug-malloc-stats   2011-06-11 11:46:23.000000000 -0400
+++ Python-2.7.2/Include/frameobject.h   2011-09-16 19:03:25.107821625 -0400
@@ -80,6 +80,8 @@ PyAPI_FUNC(void) PyFrame_FastToLocals(Py
diff --git a/Include/frameobject.h b/Include/frameobject.h
index 17e7679..66d9d8b 100644
--- a/Include/frameobject.h
+++ b/Include/frameobject.h
@@ -80,6 +80,8 @@ PyAPI_FUNC(void) PyFrame_FastToLocals(PyFrameObject *);
 
 PyAPI_FUNC(int) PyFrame_ClearFreeList(void);
 
@@ -33,10 +36,11 @@
 /* Return the line of code the frame is currently executing. */
 PyAPI_FUNC(int) PyFrame_GetLineNumber(PyFrameObject *);
 
diff -up Python-2.7.2/Include/intobject.h.add-debug-malloc-stats Python-2.7.2/Include/intobject.h
--- Python-2.7.2/Include/intobject.h.add-debug-malloc-stats   2011-06-11 11:46:23.000000000 -0400
+++ Python-2.7.2/Include/intobject.h   2011-09-16 19:03:25.107821625 -0400
@@ -74,6 +74,8 @@ PyAPI_FUNC(PyObject *) _PyInt_FormatAdva
diff --git a/Include/intobject.h b/Include/intobject.h
index 252eea9..4003736 100644
--- a/Include/intobject.h
+++ b/Include/intobject.h
@@ -75,6 +75,8 @@ PyAPI_FUNC(PyObject *) _PyInt_FormatAdvanced(PyObject *obj,
                     char *format_spec,
                     Py_ssize_t format_spec_len);
 
@@ -45,10 +49,11 @@
 #ifdef __cplusplus
 }
 #endif
diff -up Python-2.7.2/Include/listobject.h.add-debug-malloc-stats Python-2.7.2/Include/listobject.h
--- Python-2.7.2/Include/listobject.h.add-debug-malloc-stats   2011-06-11 11:46:23.000000000 -0400
+++ Python-2.7.2/Include/listobject.h   2011-09-16 19:03:25.107821625 -0400
@@ -62,6 +62,8 @@ PyAPI_FUNC(PyObject *) _PyList_Extend(Py
diff --git a/Include/listobject.h b/Include/listobject.h
index c445873..04664d7 100644
--- a/Include/listobject.h
+++ b/Include/listobject.h
@@ -62,6 +62,8 @@ PyAPI_FUNC(PyObject *) _PyList_Extend(PyListObject *, PyObject *);
 #define PyList_SET_ITEM(op, i, v) (((PyListObject *)(op))->ob_item[i] = (v))
 #define PyList_GET_SIZE(op)    Py_SIZE(op)
 
@@ -57,9 +62,10 @@
 #ifdef __cplusplus
 }
 #endif
diff -up Python-2.7.2/Include/methodobject.h.add-debug-malloc-stats Python-2.7.2/Include/methodobject.h
--- Python-2.7.2/Include/methodobject.h.add-debug-malloc-stats   2011-06-11 11:46:23.000000000 -0400
+++ Python-2.7.2/Include/methodobject.h   2011-09-16 19:03:25.108821625 -0400
diff --git a/Include/methodobject.h b/Include/methodobject.h
index 6e160b6..1944517 100644
--- a/Include/methodobject.h
+++ b/Include/methodobject.h
@@ -87,6 +87,10 @@ typedef struct {
 
 PyAPI_FUNC(int) PyCFunction_ClearFreeList(void);
@@ -71,10 +77,11 @@
 #ifdef __cplusplus
 }
 #endif
diff -up Python-2.7.2/Include/object.h.add-debug-malloc-stats Python-2.7.2/Include/object.h
--- Python-2.7.2/Include/object.h.add-debug-malloc-stats   2011-06-11 11:46:23.000000000 -0400
+++ Python-2.7.2/Include/object.h   2011-09-16 19:03:25.108821625 -0400
@@ -980,6 +980,13 @@ PyAPI_DATA(PyObject *) _PyTrash_delete_l
diff --git a/Include/object.h b/Include/object.h
index afbc68d..ce5febf 100644
--- a/Include/object.h
+++ b/Include/object.h
@@ -1005,6 +1005,13 @@ PyAPI_FUNC(void) _PyTrash_thread_destroy_chain(void);
             _PyTrash_thread_deposit_object((PyObject*)op); \
     } while (0);
 
@@ -88,9 +95,10 @@
 #ifdef __cplusplus
 }
 #endif
diff -up Python-2.7.2/Include/objimpl.h.add-debug-malloc-stats Python-2.7.2/Include/objimpl.h
--- Python-2.7.2/Include/objimpl.h.add-debug-malloc-stats   2011-06-11 11:46:23.000000000 -0400
+++ Python-2.7.2/Include/objimpl.h   2011-09-16 19:03:25.108821625 -0400
diff --git a/Include/objimpl.h b/Include/objimpl.h
index 55e83ec..331b456 100644
--- a/Include/objimpl.h
+++ b/Include/objimpl.h
@@ -101,13 +101,13 @@ PyAPI_FUNC(void) PyObject_Free(void *);
 
 /* Macros */
@@ -106,10 +114,23 @@
 PyAPI_FUNC(void *) _PyObject_DebugMallocApi(char api, size_t nbytes);
 PyAPI_FUNC(void *) _PyObject_DebugReallocApi(char api, void *p, size_t nbytes);
 PyAPI_FUNC(void) _PyObject_DebugFreeApi(char api, void *p);
diff -up Python-2.7.2/Include/stringobject.h.add-debug-malloc-stats Python-2.7.2/Include/stringobject.h
--- Python-2.7.2/Include/stringobject.h.add-debug-malloc-stats   2011-06-11 11:46:23.000000000 -0400
+++ Python-2.7.2/Include/stringobject.h   2011-09-16 19:03:25.109821625 -0400
@@ -204,6 +204,8 @@ PyAPI_FUNC(PyObject *) _PyBytes_FormatAd
diff --git a/Include/setobject.h b/Include/setobject.h
index 52b07d5..143b175 100644
--- a/Include/setobject.h
+++ b/Include/setobject.h
@@ -93,6 +93,7 @@ PyAPI_FUNC(int) _PySet_NextEntry(PyObject *set, Py_ssize_t *pos, PyObject **key,
 PyAPI_FUNC(PyObject *) PySet_Pop(PyObject *set);
 PyAPI_FUNC(int) _PySet_Update(PyObject *set, PyObject *iterable);
+PyAPI_FUNC(void) _PySet_DebugMallocStats(FILE *out);
 #ifdef __cplusplus
 }
 #endif
diff --git a/Include/stringobject.h b/Include/stringobject.h
index 18b5b41..de78d76 100644
--- a/Include/stringobject.h
+++ b/Include/stringobject.h
@@ -204,6 +204,8 @@ PyAPI_FUNC(PyObject *) _PyBytes_FormatAdvanced(PyObject *obj,
                       char *format_spec,
                       Py_ssize_t format_spec_len);
 
@@ -118,9 +139,23 @@
 #ifdef __cplusplus
 }
 #endif
diff -up Python-2.7.2/Include/unicodeobject.h.add-debug-malloc-stats Python-2.7.2/Include/unicodeobject.h
--- Python-2.7.2/Include/unicodeobject.h.add-debug-malloc-stats   2011-06-11 11:46:23.000000000 -0400
+++ Python-2.7.2/Include/unicodeobject.h   2011-09-16 19:03:25.109821625 -0400
diff --git a/Include/tupleobject.h b/Include/tupleobject.h
index a5ab733..e233f47 100644
--- a/Include/tupleobject.h
+++ b/Include/tupleobject.h
@@ -54,7 +54,7 @@ PyAPI_FUNC(void) _PyTuple_MaybeUntrack(PyObject *);
 #define PyTuple_SET_ITEM(op, i, v) (((PyTupleObject *)(op))->ob_item[i] = v)
 PyAPI_FUNC(int) PyTuple_ClearFreeList(void);
-
+PyAPI_FUNC(void) _PyTuple_DebugMallocStats(FILE *out);
 #ifdef __cplusplus
 }
 #endif
diff --git a/Include/unicodeobject.h b/Include/unicodeobject.h
index 9ab724a..b91250a 100644
--- a/Include/unicodeobject.h
+++ b/Include/unicodeobject.h
@@ -1406,6 +1406,8 @@ PyAPI_FUNC(int) _PyUnicode_IsAlpha(
     Py_UNICODE ch       /* Unicode character */
     );
@@ -130,10 +165,11 @@
 #ifdef __cplusplus
 }
 #endif
diff -up Python-2.7.2/Lib/test/test_sys.py.add-debug-malloc-stats Python-2.7.2/Lib/test/test_sys.py
--- Python-2.7.2/Lib/test/test_sys.py.add-debug-malloc-stats   2011-09-16 19:03:25.048821626 -0400
+++ Python-2.7.2/Lib/test/test_sys.py   2011-09-16 19:03:25.110821625 -0400
@@ -473,6 +473,32 @@ class SysModuleTest(unittest.TestCase):
diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py
index 82243f3..8f1e1a0 100644
--- a/Lib/test/test_sys.py
+++ b/Lib/test/test_sys.py
@@ -488,6 +488,32 @@ class SysModuleTest(unittest.TestCase):
         p.wait()
         self.assertIn(executable, ["''", repr(sys.executable)])
 
@@ -149,7 +185,7 @@
+        out, err = p.communicate()
+        p.wait()
+        self.assertIn("arenas allocated current", err)
+
+
+        # Verify that we can redirect the output to a file (not a file-like
+        # object, though):
+        with open('mallocstats.txt', 'w') as out:
@@ -161,15 +197,16 @@
+        # Verify that the destination must be a file:
+        with self.assertRaises(TypeError):
+            sys._debugmallocstats(42)
+
+
+
 class SizeofTest(unittest.TestCase):
 
     def setUp(self):
diff -up Python-2.7.2/Objects/classobject.c.add-debug-malloc-stats Python-2.7.2/Objects/classobject.c
--- Python-2.7.2/Objects/classobject.c.add-debug-malloc-stats   2011-06-11 11:46:27.000000000 -0400
+++ Python-2.7.2/Objects/classobject.c   2011-09-16 19:03:25.110821625 -0400
@@ -2670,3 +2670,12 @@ PyMethod_Fini(void)
diff --git a/Objects/classobject.c b/Objects/classobject.c
index 2c9c216..2ba7077 100644
--- a/Objects/classobject.c
+++ b/Objects/classobject.c
@@ -2694,3 +2694,12 @@ PyMethod_Fini(void)
 {
     (void)PyMethod_ClearFreeList();
 }
@@ -182,9 +219,10 @@
+                           "free PyMethodObject",
+                           numfree, sizeof(PyMethodObject));
+}
diff -up Python-2.7.2/Objects/dictobject.c.add-debug-malloc-stats Python-2.7.2/Objects/dictobject.c
--- Python-2.7.2/Objects/dictobject.c.add-debug-malloc-stats   2011-06-11 11:46:27.000000000 -0400
+++ Python-2.7.2/Objects/dictobject.c   2011-09-16 19:03:25.111821625 -0400
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index ba36b18..b8a5c7f 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -225,6 +225,15 @@ show_track(void)
 static PyDictObject *free_list[PyDict_MAXFREELIST];
 static int numfree = 0;
@@ -201,9 +239,10 @@
 void
 PyDict_Fini(void)
 {
diff -up Python-2.7.2/Objects/floatobject.c.add-debug-malloc-stats Python-2.7.2/Objects/floatobject.c
--- Python-2.7.2/Objects/floatobject.c.add-debug-malloc-stats   2011-06-11 11:46:27.000000000 -0400
+++ Python-2.7.2/Objects/floatobject.c   2011-09-16 19:03:25.111821625 -0400
diff --git a/Objects/floatobject.c b/Objects/floatobject.c
index ba867ef..533511d 100644
--- a/Objects/floatobject.c
+++ b/Objects/floatobject.c
@@ -35,6 +35,22 @@ typedef struct _floatblock PyFloatBlock;
 static PyFloatBlock *block_list = NULL;
 static PyFloatObject *free_list = NULL;
@@ -227,10 +266,11 @@
 static PyFloatObject *
 fill_free_list(void)
 {
diff -up Python-2.7.2/Objects/frameobject.c.add-debug-malloc-stats Python-2.7.2/Objects/frameobject.c
--- Python-2.7.2/Objects/frameobject.c.add-debug-malloc-stats   2011-06-11 11:46:27.000000000 -0400
+++ Python-2.7.2/Objects/frameobject.c   2011-09-16 19:03:25.112821625 -0400
@@ -980,3 +980,13 @@ PyFrame_Fini(void)
diff --git a/Objects/frameobject.c b/Objects/frameobject.c
index f9e4a0e..337fc58 100644
--- a/Objects/frameobject.c
+++ b/Objects/frameobject.c
@@ -982,3 +982,13 @@ PyFrame_Fini(void)
     Py_XDECREF(builtin_object);
     builtin_object = NULL;
 }
@@ -244,9 +284,10 @@
+                           numfree, sizeof(PyFrameObject));
+}
+
diff -up Python-2.7.2/Objects/intobject.c.add-debug-malloc-stats Python-2.7.2/Objects/intobject.c
--- Python-2.7.2/Objects/intobject.c.add-debug-malloc-stats   2011-06-11 11:46:27.000000000 -0400
+++ Python-2.7.2/Objects/intobject.c   2011-09-16 19:03:25.112821625 -0400
diff --git a/Objects/intobject.c b/Objects/intobject.c
index 28182f9..f442ea0 100644
--- a/Objects/intobject.c
+++ b/Objects/intobject.c
@@ -44,6 +44,23 @@ typedef struct _intblock PyIntBlock;
 static PyIntBlock *block_list = NULL;
 static PyIntObject *free_list = NULL;
@@ -271,9 +312,10 @@
 static PyIntObject *
 fill_free_list(void)
 {
diff -up Python-2.7.2/Objects/listobject.c.add-debug-malloc-stats Python-2.7.2/Objects/listobject.c
--- Python-2.7.2/Objects/listobject.c.add-debug-malloc-stats   2011-06-11 11:46:27.000000000 -0400
+++ Python-2.7.2/Objects/listobject.c   2011-09-16 19:03:25.113821625 -0400
diff --git a/Objects/listobject.c b/Objects/listobject.c
index f753643..e6fa17d 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -109,6 +109,15 @@ PyList_Fini(void)
     }
 }
@@ -290,9 +332,10 @@
 PyObject *
 PyList_New(Py_ssize_t size)
 {
diff -up Python-2.7.2/Objects/methodobject.c.add-debug-malloc-stats Python-2.7.2/Objects/methodobject.c
--- Python-2.7.2/Objects/methodobject.c.add-debug-malloc-stats   2011-06-11 11:46:27.000000000 -0400
+++ Python-2.7.2/Objects/methodobject.c   2011-09-16 19:03:25.113821625 -0400
diff --git a/Objects/methodobject.c b/Objects/methodobject.c
index 0b60ca3..3193135 100644
--- a/Objects/methodobject.c
+++ b/Objects/methodobject.c
@@ -412,6 +412,15 @@ PyCFunction_Fini(void)
     (void)PyCFunction_ClearFreeList();
 }
@@ -309,10 +352,11 @@
 /* PyCFunction_New() is now just a macro that calls PyCFunction_NewEx(),
    but it's part of the API so we need to keep a function around that
    existing C extensions can call.
diff -up Python-2.7.2/Objects/object.c.add-debug-malloc-stats Python-2.7.2/Objects/object.c
--- Python-2.7.2/Objects/object.c.add-debug-malloc-stats   2011-06-11 11:46:27.000000000 -0400
+++ Python-2.7.2/Objects/object.c   2011-09-16 19:04:46.463820849 -0400
@@ -2334,6 +2334,23 @@ PyMem_Free(void *p)
diff --git a/Objects/object.c b/Objects/object.c
index 14f4e9f..68aedcd 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -2355,6 +2355,23 @@ PyMem_Free(void *p)
     PyMem_FREE(p);
 }
 
@@ -336,10 +380,11 @@
 
 /* These methods are used to control infinite recursion in repr, str, print,
    etc.  Container objects that may recursively contain themselves,
diff -up Python-2.7.2/Objects/obmalloc.c.add-debug-malloc-stats Python-2.7.2/Objects/obmalloc.c
--- Python-2.7.2/Objects/obmalloc.c.add-debug-malloc-stats   2011-06-11 11:46:27.000000000 -0400
+++ Python-2.7.2/Objects/obmalloc.c   2011-09-16 19:03:25.114821625 -0400
@@ -508,12 +508,10 @@ static struct arena_object* usable_arena
diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c
index 38ebc37..2c05359 100644
--- a/Objects/obmalloc.c
+++ b/Objects/obmalloc.c
@@ -508,12 +508,10 @@ static struct arena_object* usable_arenas = NULL;
 /* Number of arenas allocated that haven't been free()'d. */
 static size_t narenas_currently_allocated = 0;
 
@@ -373,7 +418,7 @@
     arenaobj->freepools = NULL;
     /* pool_address <- first pool-aligned address in the arena
        nfreepools <- number of whole pools that fit after alignment */
@@ -1694,17 +1690,19 @@ _PyObject_DebugDumpAddress(const void *p
@@ -1694,17 +1690,19 @@ _PyObject_DebugDumpAddress(const void *p)
     }
 }
 
@@ -518,9 +563,10 @@
 #ifdef Py_USING_MEMORY_DEBUGGER
 /* Make this function last so gcc won't inline it since the definition is
  * after the reference.
diff -up Python-2.7.2/Objects/setobject.c.add-debug-malloc-stats Python-2.7.2/Objects/setobject.c
--- Python-2.7.2/Objects/setobject.c.add-debug-malloc-stats   2011-06-11 11:46:27.000000000 -0400
+++ Python-2.7.2/Objects/setobject.c   2011-09-16 19:03:25.115821625 -0400
diff --git a/Objects/setobject.c b/Objects/setobject.c
index af1ce16..3439b7c 100644
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -1088,6 +1088,16 @@ PySet_Fini(void)
     Py_CLEAR(emptyfrozenset);
 }
@@ -538,10 +584,11 @@
 static PyObject *
 set_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
 {
diff -up Python-2.7.2/Objects/stringobject.c.add-debug-malloc-stats Python-2.7.2/Objects/stringobject.c
--- Python-2.7.2/Objects/stringobject.c.add-debug-malloc-stats   2011-06-11 11:46:27.000000000 -0400
+++ Python-2.7.2/Objects/stringobject.c   2011-09-16 19:03:25.116821625 -0400
@@ -4822,3 +4822,43 @@ void _Py_ReleaseInternedStrings(void)
diff --git a/Objects/stringobject.c b/Objects/stringobject.c
index 1209197..b8646dd 100644
--- a/Objects/stringobject.c
+++ b/Objects/stringobject.c
@@ -4843,3 +4843,43 @@ void _Py_ReleaseInternedStrings(void)
     PyDict_Clear(interned);
     Py_CLEAR(interned);
 }
@@ -585,9 +632,10 @@
+            "%zi/%zi "
+            "mortal/immortal\n", mortal_size, immortal_size);
+}
diff -up Python-2.7.2/Objects/tupleobject.c.add-debug-malloc-stats Python-2.7.2/Objects/tupleobject.c
--- Python-2.7.2/Objects/tupleobject.c.add-debug-malloc-stats   2011-06-11 11:46:27.000000000 -0400
+++ Python-2.7.2/Objects/tupleobject.c   2011-09-16 19:03:25.116821625 -0400
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c
index 00f2e47..7682d81 100644
--- a/Objects/tupleobject.c
+++ b/Objects/tupleobject.c
@@ -44,6 +44,22 @@ show_track(void)
 }
 #endif
@@ -611,10 +659,11 @@
 
 PyObject *
 PyTuple_New(register Py_ssize_t size)
diff -up Python-2.7.2/Objects/unicodeobject.c.add-debug-malloc-stats Python-2.7.2/Objects/unicodeobject.c
--- Python-2.7.2/Objects/unicodeobject.c.add-debug-malloc-stats   2011-06-11 11:46:27.000000000 -0400
+++ Python-2.7.2/Objects/unicodeobject.c   2011-09-16 19:03:25.118821625 -0400
@@ -8883,6 +8883,12 @@ _PyUnicode_Fini(void)
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 6bea370..ced9acf 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -8920,6 +8920,12 @@ _PyUnicode_Fini(void)
     (void)PyUnicode_ClearFreeList();
 }
 
@@ -627,10 +676,11 @@
 #ifdef __cplusplus
 }
 #endif
diff -up Python-2.7.2/Python/pythonrun.c.add-debug-malloc-stats Python-2.7.2/Python/pythonrun.c
--- Python-2.7.2/Python/pythonrun.c.add-debug-malloc-stats   2011-09-16 19:03:25.025821626 -0400
+++ Python-2.7.2/Python/pythonrun.c   2011-09-16 19:03:25.118821625 -0400
@@ -549,7 +549,7 @@ Py_Finalize(void)
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index f0fbd74..0b73f3a 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -557,7 +557,7 @@ Py_Finalize(void)
 #endif /* Py_TRACE_REFS */
 #ifdef PYMALLOC_DEBUG
     if (Py_GETENV("PYTHONMALLOCSTATS"))
@@ -639,10 +689,11 @@
 #endif
 
     call_ll_exitfuncs();
diff -up Python-2.7.2/Python/sysmodule.c.add-debug-malloc-stats Python-2.7.2/Python/sysmodule.c
--- Python-2.7.2/Python/sysmodule.c.add-debug-malloc-stats   2011-09-16 19:03:25.007821626 -0400
+++ Python-2.7.2/Python/sysmodule.c   2011-09-16 19:03:25.119821625 -0400
@@ -872,6 +872,57 @@ a 11-tuple where the entries in the tupl
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index 2a7c207..fbb637b 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -873,6 +873,57 @@ a 11-tuple where the entries in the tuple are counts of:\n\
 extern "C" {
 #endif
 
@@ -676,7 +727,7 @@
+    if (!fp) {
+        PyErr_SetString(PyExc_ValueError, "file is closed");
+        Py_DECREF(file);
+        return NULL;
+        return NULL;
+    }
+
+    _PyObject_DebugMallocStats(fp);
@@ -700,7 +751,7 @@
 #ifdef Py_TRACE_REFS
 /* Defined in objects.c because it uses static globals if that file */
 extern PyObject *_Py_GetObjects(PyObject *, PyObject *);
@@ -970,6 +1021,8 @@ static PyMethodDef sys_methods[] = {
@@ -971,6 +1022,8 @@ static PyMethodDef sys_methods[] = {
     {"settrace",        sys_settrace, METH_O, settrace_doc},
     {"gettrace",        sys_gettrace, METH_NOARGS, gettrace_doc},
     {"call_tracing", sys_call_tracing, METH_VARARGS, call_tracing_doc},