mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
- PEP 3106: dict.iterkeys(), .iteritems(), .itervalues() are now gone;
and .keys(), .items(), .values() return dict views. The dict views aren't fully functional yet; in particular, they can't be compared to sets yet. but they are useful as "iterator wells". There are still 27 failing unit tests; I expect that many of these have fairly trivial fixes, but there are so many, I could use help.
This commit is contained in:
parent
4e66dfcdc4
commit
cc2b016125
73 changed files with 317 additions and 272 deletions
|
|
@ -290,8 +290,8 @@ class BuiltinTest(unittest.TestCase):
|
|||
if key == 'a':
|
||||
return 12
|
||||
raise KeyError
|
||||
def keys(self):
|
||||
return list('xyz')
|
||||
def __iter__(self):
|
||||
return iter('xyz')
|
||||
|
||||
m = M()
|
||||
g = globals()
|
||||
|
|
@ -313,8 +313,8 @@ class BuiltinTest(unittest.TestCase):
|
|||
if key == 'a':
|
||||
return 12
|
||||
return dict.__getitem__(self, key)
|
||||
def keys(self):
|
||||
return list('xyz')
|
||||
def __iter__(self):
|
||||
return iter('xyz')
|
||||
|
||||
d = D()
|
||||
self.assertEqual(eval('a', g, d), 12)
|
||||
|
|
@ -346,8 +346,8 @@ class BuiltinTest(unittest.TestCase):
|
|||
class C:
|
||||
def __getitem__(self, item):
|
||||
raise KeyError(item)
|
||||
def keys(self):
|
||||
return 'a'
|
||||
def __iter__(self):
|
||||
return 'a' # XXX Not quite faithful to the SF bug...
|
||||
self.assertRaises(TypeError, eval, 'dir()', globals(), C())
|
||||
|
||||
# Done outside of the method test_z to get the correct scope
|
||||
|
|
@ -522,8 +522,8 @@ class BuiltinTest(unittest.TestCase):
|
|||
unicode("123"): unicode("112233")
|
||||
}
|
||||
|
||||
for (cls, inps) in inputs.iteritems():
|
||||
for (inp, exp) in inps.iteritems():
|
||||
for (cls, inps) in inputs.items():
|
||||
for (inp, exp) in inps.items():
|
||||
# make sure the output goes through __getitem__
|
||||
# even if func is None
|
||||
self.assertEqual(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue