[Python-checkins] r46600 - in python/trunk: Lib/test/test_exceptions.py Objects/exceptions.c

neal.norwitz python-checkins at python.org
Fri Jun 2 06:50:55 CEST 2006


Author: neal.norwitz
Date: Fri Jun  2 06:50:49 2006
New Revision: 46600

Modified:
   python/trunk/Lib/test/test_exceptions.py
   python/trunk/Objects/exceptions.c
Log:
Fix memory leak found by valgrind.


Modified: python/trunk/Lib/test/test_exceptions.py
==============================================================================
--- python/trunk/Lib/test/test_exceptions.py	(original)
+++ python/trunk/Lib/test/test_exceptions.py	Fri Jun  2 06:50:49 2006
@@ -265,7 +265,9 @@
                 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 @@
 
                 # 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' %

Modified: python/trunk/Objects/exceptions.c
==============================================================================
--- python/trunk/Objects/exceptions.c	(original)
+++ python/trunk/Objects/exceptions.c	Fri Jun  2 06:50:49 2006
@@ -619,7 +619,6 @@
             PyTuple_SET_ITEM(tuple, 1, Py_None);
         }
 
-        Py_INCREF(repr);
         PyTuple_SET_ITEM(tuple, 2, repr);
 
         rtnval = PyString_Format(fmt, tuple);


More information about the Python-checkins mailing list