diff options
author | Michael W. Hudson <mwh@python.net> | 2005-07-12 10:21:19 (GMT) |
---|---|---|
committer | Michael W. Hudson <mwh@python.net> | 2005-07-12 10:21:19 (GMT) |
commit | 0edc7a03e2505c4e9b3186f8b6caa18a7b3988e2 (patch) | |
tree | c192e6bf89c8bcbcdd869a01bbec4cc3981a1f6a /Lib | |
parent | 208eec2cad5dcfdd7fe2c8fa706ec5e89533c87d (diff) | |
download | cpython-0edc7a03e2505c4e9b3186f8b6caa18a7b3988e2.zip cpython-0edc7a03e2505c4e9b3186f8b6caa18a7b3988e2.tar.gz cpython-0edc7a03e2505c4e9b3186f8b6caa18a7b3988e2.tar.bz2 |
Fix:
[ 1229429 ] missing Py_DECREF in PyObject_CallMethod
Add a test in test_enumerate, which is a bit random, but suffices
(reversed_new calls PyObject_CallMethod under some circumstances).
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_enumerate.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_enumerate.py b/Lib/test/test_enumerate.py index 0ed2b4c..0a88e8d 100644 --- a/Lib/test/test_enumerate.py +++ b/Lib/test/test_enumerate.py @@ -1,4 +1,5 @@ import unittest +import sys from test import test_support @@ -175,6 +176,25 @@ class TestReversed(unittest.TestCase): self.assertRaises(TypeError, reversed) self.assertRaises(TypeError, reversed, [], 'extra') + def test_bug1229429(self): + # this bug was never in reversed, it was in + # PyObject_CallMethod, and reversed_new calls that sometimes. + if not hasattr(sys, "getrefcount"): + return + def f(): + pass + r = f.__reversed__ = object() + rc = sys.getrefcount(r) + for i in range(10): + try: + reversed(f) + except TypeError: + pass + else: + self.fail("non-callable __reversed__ didn't raise!") + self.assertEqual(rc, sys.getrefcount(r)) + + def test_main(verbose=None): testclasses = (EnumerateTestCase, SubclassTestCase, TestEmpty, TestBig, TestReversed) |