Skip to content

Commit 8ea757a

Browse files
author
neal.norwitz
committed
Fix memory leak found by valgrind.
git-svn-id: http://svn.python.org/projects/python/trunk@46600 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 3c19044 commit 8ea757a

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

Lib/test/test_exceptions.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,15 +265,17 @@ def testAttributes(self):
265265
if (e is not exc and # needed for sampleUnicode errors
266266
type(e) is not exc):
267267
raise
268-
for checkArgName in expected.keys():
268+
# Verify no ref leaks in Exc_str()
269+
s = str(e)
270+
for checkArgName in expected:
269271
self.assertEquals(repr(getattr(e, checkArgName)),
270272
repr(expected[checkArgName]),
271273
'exception "%s", attribute "%s"' %
272274
(repr(e), checkArgName))
273275

274276
# test for pickling support
275277
new = pickle.loads(pickle.dumps(e, random.randint(0, 2)))
276-
for checkArgName in expected.keys():
278+
for checkArgName in expected:
277279
self.assertEquals(repr(getattr(e, checkArgName)),
278280
repr(expected[checkArgName]),
279281
'pickled exception "%s", attribute "%s' %

Objects/exceptions.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,6 @@ EnvironmentError_str(PyEnvironmentErrorObject *self)
619619
PyTuple_SET_ITEM(tuple, 1, Py_None);
620620
}
621621

622-
Py_INCREF(repr);
623622
PyTuple_SET_ITEM(tuple, 2, repr);
624623

625624
rtnval = PyString_Format(fmt, tuple);

0 commit comments

Comments
 (0)