]> granicus.if.org Git - python/commitdiff
Fix memory leak found by valgrind.
authorNeal Norwitz <nnorwitz@gmail.com>
Fri, 2 Jun 2006 04:50:49 +0000 (04:50 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Fri, 2 Jun 2006 04:50:49 +0000 (04:50 +0000)
Lib/test/test_exceptions.py
Objects/exceptions.c

index 8bd385ad381d487ce2e8f9b65df85d7edb05b79c..84d2798e6ea5af9a267f83962498b33ad4f158f1 100644 (file)
@@ -265,7 +265,9 @@ class ExceptionTests(unittest.TestCase):
                 if (e is not exc and     # needed for sampleUnicode errors
                     type(e) is not exc):
                     raise
-                for checkArgName in expected.keys():
+                # Verify no ref leaks in Exc_str()
+                s = str(e)
+                for checkArgName in expected:
                     self.assertEquals(repr(getattr(e, checkArgName)),
                                       repr(expected[checkArgName]),
                                       'exception "%s", attribute "%s"' %
@@ -273,7 +275,7 @@ class ExceptionTests(unittest.TestCase):
 
                 # test for pickling support
                 new = pickle.loads(pickle.dumps(e, random.randint(0, 2)))
-                for checkArgName in expected.keys():
+                for checkArgName in expected:
                     self.assertEquals(repr(getattr(e, checkArgName)),
                                       repr(expected[checkArgName]),
                                       'pickled exception "%s", attribute "%s' %
index acc7da50c16119e52df393efe6d443cef3d55700..3b79307406114f88dd58c9efcc4d4aa39e152139 100644 (file)
@@ -619,7 +619,6 @@ EnvironmentError_str(PyEnvironmentErrorObject *self)
             PyTuple_SET_ITEM(tuple, 1, Py_None);
         }
 
-        Py_INCREF(repr);
         PyTuple_SET_ITEM(tuple, 2, repr);
 
         rtnval = PyString_Format(fmt, tuple);