diff options
author | Raymond Hettinger <python@rcn.com> | 2015-05-17 21:47:00 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2015-05-17 21:47:00 (GMT) |
commit | 740d6134f15cd9641a7c9d953269a07a99d02a2b (patch) | |
tree | e8955d6fe74b3a5315361cc2155311a53c7a1d8e | |
parent | 01d566d340f23f1d4568fa78efdd3541c5a145bf (diff) | |
parent | 610a51f364f6cb5ffb5167d9bf4dcecc1815107c (diff) | |
download | cpython-740d6134f15cd9641a7c9d953269a07a99d02a2b.zip cpython-740d6134f15cd9641a7c9d953269a07a99d02a2b.tar.gz cpython-740d6134f15cd9641a7c9d953269a07a99d02a2b.tar.bz2 |
merge
-rw-r--r-- | Lib/test/seq_tests.py | 12 | ||||
-rw-r--r-- | Objects/abstract.c | 2 |
2 files changed, 13 insertions, 1 deletions
diff --git a/Lib/test/seq_tests.py b/Lib/test/seq_tests.py index 9834af1..2416249 100644 --- a/Lib/test/seq_tests.py +++ b/Lib/test/seq_tests.py @@ -85,6 +85,14 @@ def itermulti(seqn): 'Test multiple tiers of iterators' return chain(map(lambda x:x, iterfunc(IterGen(Sequence(seqn))))) +class LyingTuple(tuple): + def __iter__(self): + yield 1 + +class LyingList(list): + def __iter__(self): + yield 1 + class CommonTest(unittest.TestCase): # The type to be tested type2test = None @@ -131,6 +139,10 @@ class CommonTest(unittest.TestCase): self.assertRaises(TypeError, self.type2test, IterNoNext(s)) self.assertRaises(ZeroDivisionError, self.type2test, IterGenExc(s)) + # Issue #23757 + self.assertEqual(self.type2test(LyingTuple((2,))), self.type2test((1,))) + self.assertEqual(self.type2test(LyingList([2])), self.type2test([1])) + def test_truth(self): self.assertFalse(self.type2test()) self.assertTrue(self.type2test([42])) diff --git a/Objects/abstract.c b/Objects/abstract.c index dc8fb37..31cc0a8 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -1681,7 +1681,7 @@ PySequence_Tuple(PyObject *v) Py_INCREF(v); return v; } - if (PyList_Check(v)) + if (PyList_CheckExact(v)) return PyList_AsTuple(v); /* Get iterator. */ |