mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
PEP 3114: rename .next() to .__next__() and add next() builtin.
This commit is contained in:
parent
4d2adcca52
commit
a18af4e7a2
83 changed files with 495 additions and 425 deletions
|
@ -144,7 +144,7 @@ class DictTest(unittest.TestCase):
|
|||
self.i = 1
|
||||
def __iter__(self):
|
||||
return self
|
||||
def next(self):
|
||||
def __next__(self):
|
||||
if self.i:
|
||||
self.i = 0
|
||||
return 'a'
|
||||
|
@ -161,7 +161,7 @@ class DictTest(unittest.TestCase):
|
|||
self.i = ord('a')
|
||||
def __iter__(self):
|
||||
return self
|
||||
def next(self):
|
||||
def __next__(self):
|
||||
if self.i <= ord('z'):
|
||||
rtn = chr(self.i)
|
||||
self.i += 1
|
||||
|
@ -175,7 +175,7 @@ class DictTest(unittest.TestCase):
|
|||
class badseq(object):
|
||||
def __iter__(self):
|
||||
return self
|
||||
def next(self):
|
||||
def __next__(self):
|
||||
raise Exc()
|
||||
|
||||
self.assertRaises(Exc, {}.update, badseq())
|
||||
|
@ -225,7 +225,7 @@ class DictTest(unittest.TestCase):
|
|||
class BadSeq(object):
|
||||
def __iter__(self):
|
||||
return self
|
||||
def next(self):
|
||||
def __next__(self):
|
||||
raise Exc()
|
||||
|
||||
self.assertRaises(Exc, dict.fromkeys, BadSeq())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue