[Python-checkins] cpython (merge 3.4 -> default): merge
raymond.hettinger
python-checkins at python.org
Sun May 17 23:47:10 CEST 2015
https://hg.python.org/cpython/rev/257ea04df092
changeset: 96125:257ea04df092
parent: 96122:850cbd54cc73
parent: 96124:c79530e08985
user: Raymond Hettinger <python at rcn.com>
date: Sun May 17 14:47:00 2015 -0700
summary:
merge
files:
Lib/test/seq_tests.py | 12 ++++++++++++
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
--- a/Lib/test/seq_tests.py
+++ b/Lib/test/seq_tests.py
@@ -85,6 +85,14 @@
'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 @@
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
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -1681,7 +1681,7 @@
Py_INCREF(v);
return v;
}
- if (PyList_Check(v))
+ if (PyList_CheckExact(v))
return PyList_AsTuple(v);
/* Get iterator. */
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list