summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2014-11-23 06:14:41 (GMT)
committerRaymond Hettinger <python@rcn.com>2014-11-23 06:14:41 (GMT)
commitbb6c0aaebfbeb9ab13886e261df904c9c12853b9 (patch)
treeaa283779a1ce070feb4c59a8c5cf624d3830059c /Lib
parent828d932a2c4da5eb7c05e85dfe51f5f6db68084d (diff)
downloadcpython-bb6c0aaebfbeb9ab13886e261df904c9c12853b9.zip
cpython-bb6c0aaebfbeb9ab13886e261df904c9c12853b9.tar.gz
cpython-bb6c0aaebfbeb9ab13886e261df904c9c12853b9.tar.bz2
PEP 479: Use the return-keyword instead of raising StopIteration inside a generators.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/ipaddress.py2
-rw-r--r--Lib/mailbox.py2
-rw-r--r--Lib/test/test_buffer.py2
-rw-r--r--Lib/test/test_collections.py2
-rw-r--r--Lib/test/test_itertools.py2
-rw-r--r--Lib/test/test_sys_setprofile.py1
6 files changed, 4 insertions, 7 deletions
diff --git a/Lib/ipaddress.py b/Lib/ipaddress.py
index d15a1d9..b32a7e1 100644
--- a/Lib/ipaddress.py
+++ b/Lib/ipaddress.py
@@ -808,7 +808,7 @@ class _BaseNetwork(_IPAddressBase):
other.broadcast_address <= self.broadcast_address):
raise ValueError('%s not contained in %s' % (other, self))
if other == self:
- raise StopIteration
+ return
# Make sure we're comparing the network of other.
other = other.__class__('%s/%s' % (other.network_address,
diff --git a/Lib/mailbox.py b/Lib/mailbox.py
index 145b204..e7f31df 100644
--- a/Lib/mailbox.py
+++ b/Lib/mailbox.py
@@ -1949,7 +1949,7 @@ class _ProxyFile:
while True:
line = self.readline()
if not line:
- raise StopIteration
+ return
yield line
def tell(self):
diff --git a/Lib/test/test_buffer.py b/Lib/test/test_buffer.py
index 1667847..1cdc771 100644
--- a/Lib/test/test_buffer.py
+++ b/Lib/test/test_buffer.py
@@ -216,7 +216,7 @@ def iter_format(nitems, testobj='ndarray'):
for t in iter_mode(nitems, testobj):
yield t
if testobj != 'ndarray':
- raise StopIteration
+ return
yield struct_items(nitems, testobj)
diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py
index e948106..7b46475 100644
--- a/Lib/test/test_collections.py
+++ b/Lib/test/test_collections.py
@@ -511,7 +511,7 @@ class TestOneTrickPonyABCs(ABCTestCase):
class NextOnly:
def __next__(self):
yield 1
- raise StopIteration
+ return
self.assertNotIsInstance(NextOnly(), Iterator)
def test_Sized(self):
diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py
index 5f33d39..d48bf55 100644
--- a/Lib/test/test_itertools.py
+++ b/Lib/test/test_itertools.py
@@ -1803,8 +1803,6 @@ class RegressionTests(unittest.TestCase):
hist.append(3)
yield 2
hist.append(4)
- if x:
- raise StopIteration
hist = []
self.assertRaises(AssertionError, list, chain(gen1(), gen2(False)))
diff --git a/Lib/test/test_sys_setprofile.py b/Lib/test/test_sys_setprofile.py
index 9816e3e..e59320b 100644
--- a/Lib/test/test_sys_setprofile.py
+++ b/Lib/test/test_sys_setprofile.py
@@ -260,7 +260,6 @@ class ProfileHookTestCase(TestCaseBase):
def f():
for i in range(2):
yield i
- raise StopIteration
def g(p):
for i in f():
pass