summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2008-01-21 17:22:06 (GMT)
committerGeorg Brandl <georg@python.org>2008-01-21 17:22:06 (GMT)
commit1ea8cb49ed728dadec11d0a554431c566fdc5a56 (patch)
treec4e487e2d224711791204e45e7bd9e2acc36b5a1
parentaf67f303d8077b3b08e4baa03feae5f618fae757 (diff)
downloadcpython-1ea8cb49ed728dadec11d0a554431c566fdc5a56.zip
cpython-1ea8cb49ed728dadec11d0a554431c566fdc5a56.tar.gz
cpython-1ea8cb49ed728dadec11d0a554431c566fdc5a56.tar.bz2
#1726198: replace while 1: fp.readline() with file iteration.
-rw-r--r--Lib/formatter.py5
-rwxr-xr-xLib/keyword.py4
-rw-r--r--Lib/urlparse.py4
-rw-r--r--Tools/pynche/ColorDB.py5
4 files changed, 4 insertions, 14 deletions
diff --git a/Lib/formatter.py b/Lib/formatter.py
index fa2b389..834b560 100644
--- a/Lib/formatter.py
+++ b/Lib/formatter.py
@@ -432,10 +432,7 @@ def test(file = None):
fp = open(sys.argv[1])
else:
fp = sys.stdin
- while 1:
- line = fp.readline()
- if not line:
- break
+ for line in fp:
if line == '\n':
f.end_paragraph(1)
else:
diff --git a/Lib/keyword.py b/Lib/keyword.py
index cd1d55e..8eb2860 100755
--- a/Lib/keyword.py
+++ b/Lib/keyword.py
@@ -62,9 +62,7 @@ def main():
fp = open(iptfile)
strprog = re.compile('"([^"]+)"')
lines = []
- while 1:
- line = fp.readline()
- if not line: break
+ for line in fp:
if '{1, "' in line:
match = strprog.search(line)
if match:
diff --git a/Lib/urlparse.py b/Lib/urlparse.py
index ada6142..631a5a1 100644
--- a/Lib/urlparse.py
+++ b/Lib/urlparse.py
@@ -306,9 +306,7 @@ def test():
except ImportError:
from StringIO import StringIO
fp = StringIO(test_input)
- while 1:
- line = fp.readline()
- if not line: break
+ for line in fp:
words = line.split()
if not words:
continue
diff --git a/Tools/pynche/ColorDB.py b/Tools/pynche/ColorDB.py
index 96b6ce6..84a5b07 100644
--- a/Tools/pynche/ColorDB.py
+++ b/Tools/pynche/ColorDB.py
@@ -50,10 +50,7 @@ class ColorDB:
self.__byname = {}
# all unique names (non-aliases). built-on demand
self.__allnames = None
- while 1:
- line = fp.readline()
- if not line:
- break
+ for line in fp:
# get this compiled regular expression from derived class
mo = self._re.match(line)
if not mo: