summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_enumerate.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_enumerate.py')
-rw-r--r--Lib/test/test_enumerate.py20
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)