Add test for memory leak reported in issue 9422.
authorMark Dickinson <dickinsm@gmail.com>
Sun, 1 Aug 2010 11:10:28 +0000 (11:10 +0000)
committerMark Dickinson <dickinsm@gmail.com>
Sun, 1 Aug 2010 11:10:28 +0000 (11:10 +0000)
Lib/test/test_struct.py

index 6ca35ca31cf972f96b9727fbf29ae5ecd3dc879f..6ac8fdcc9c52c1911f71f965a27db63857b81040 100644 (file)
@@ -560,7 +560,12 @@ class StructTest(unittest.TestCase):
                           'spam and eggs')
         self.assertRaises(struct.error, struct.unpack_from, '14s42', store, 0)
 
-
+    def test_Struct_reinitialization(self):
+        # Issue 9422: there was a memory leak when reinitializing a
+        # Struct instance.  This test can be used to detect the leak
+        # when running with regrtest -L.
+        s = struct.Struct('i')
+        s.__init__('ii')
 
 def test_main():
     run_unittest(StructTest)