mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
merge
This commit is contained in:
commit
740d6134f1
2 changed files with 13 additions and 1 deletions
|
@ -85,6 +85,14 @@ def itermulti(seqn):
|
||||||
'Test multiple tiers of iterators'
|
'Test multiple tiers of iterators'
|
||||||
return chain(map(lambda x:x, iterfunc(IterGen(Sequence(seqn)))))
|
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):
|
class CommonTest(unittest.TestCase):
|
||||||
# The type to be tested
|
# The type to be tested
|
||||||
type2test = None
|
type2test = None
|
||||||
|
@ -131,6 +139,10 @@ class CommonTest(unittest.TestCase):
|
||||||
self.assertRaises(TypeError, self.type2test, IterNoNext(s))
|
self.assertRaises(TypeError, self.type2test, IterNoNext(s))
|
||||||
self.assertRaises(ZeroDivisionError, self.type2test, IterGenExc(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):
|
def test_truth(self):
|
||||||
self.assertFalse(self.type2test())
|
self.assertFalse(self.type2test())
|
||||||
self.assertTrue(self.type2test([42]))
|
self.assertTrue(self.type2test([42]))
|
||||||
|
|
|
@ -1681,7 +1681,7 @@ PySequence_Tuple(PyObject *v)
|
||||||
Py_INCREF(v);
|
Py_INCREF(v);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
if (PyList_Check(v))
|
if (PyList_CheckExact(v))
|
||||||
return PyList_AsTuple(v);
|
return PyList_AsTuple(v);
|
||||||
|
|
||||||
/* Get iterator. */
|
/* Get iterator. */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue