As discussed on python-dev, changed builtin.zip() to handle zero arguments

by returning an empty list instead of raising a TypeError.
This commit is contained in:
Raymond Hettinger 2003-08-02 07:42:57 +00:00
parent 9463792c68
commit eaef615116
5 changed files with 20 additions and 11 deletions

View file

@ -423,7 +423,10 @@ class TestCase(unittest.TestCase):
# Test zip()'s use of iterators.
def test_builtin_zip(self):
self.assertRaises(TypeError, zip)
self.assertEqual(zip(), [])
self.assertEqual(zip(*[]), [])
self.assertEqual(zip(*[(1, 2), 'ab']), [(1, 'a'), (2, 'b')])
self.assertRaises(TypeError, zip, None)
self.assertRaises(TypeError, zip, range(10), 42)
self.assertRaises(TypeError, zip, range(10), zip)