mirror of
https://github.com/python/cpython.git
synced 2025-11-26 21:33:10 +00:00
#1726198: replace while 1: fp.readline() with file iteration.
This commit is contained in:
parent
af67f303d8
commit
1ea8cb49ed
4 changed files with 4 additions and 14 deletions
|
|
@ -432,10 +432,7 @@ def test(file = None):
|
||||||
fp = open(sys.argv[1])
|
fp = open(sys.argv[1])
|
||||||
else:
|
else:
|
||||||
fp = sys.stdin
|
fp = sys.stdin
|
||||||
while 1:
|
for line in fp:
|
||||||
line = fp.readline()
|
|
||||||
if not line:
|
|
||||||
break
|
|
||||||
if line == '\n':
|
if line == '\n':
|
||||||
f.end_paragraph(1)
|
f.end_paragraph(1)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -62,9 +62,7 @@ def main():
|
||||||
fp = open(iptfile)
|
fp = open(iptfile)
|
||||||
strprog = re.compile('"([^"]+)"')
|
strprog = re.compile('"([^"]+)"')
|
||||||
lines = []
|
lines = []
|
||||||
while 1:
|
for line in fp:
|
||||||
line = fp.readline()
|
|
||||||
if not line: break
|
|
||||||
if '{1, "' in line:
|
if '{1, "' in line:
|
||||||
match = strprog.search(line)
|
match = strprog.search(line)
|
||||||
if match:
|
if match:
|
||||||
|
|
|
||||||
|
|
@ -306,9 +306,7 @@ def test():
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from StringIO import StringIO
|
from StringIO import StringIO
|
||||||
fp = StringIO(test_input)
|
fp = StringIO(test_input)
|
||||||
while 1:
|
for line in fp:
|
||||||
line = fp.readline()
|
|
||||||
if not line: break
|
|
||||||
words = line.split()
|
words = line.split()
|
||||||
if not words:
|
if not words:
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
|
|
@ -50,10 +50,7 @@ class ColorDB:
|
||||||
self.__byname = {}
|
self.__byname = {}
|
||||||
# all unique names (non-aliases). built-on demand
|
# all unique names (non-aliases). built-on demand
|
||||||
self.__allnames = None
|
self.__allnames = None
|
||||||
while 1:
|
for line in fp:
|
||||||
line = fp.readline()
|
|
||||||
if not line:
|
|
||||||
break
|
|
||||||
# get this compiled regular expression from derived class
|
# get this compiled regular expression from derived class
|
||||||
mo = self._re.match(line)
|
mo = self._re.match(line)
|
||||||
if not mo:
|
if not mo:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue