]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
#1726198: replace while 1: fp.readline() with file iteration.
authorGeorg Brandl <georg@python.org>
Mon, 21 Jan 2008 17:22:06 +0000 (17:22 +0000)
committerGeorg Brandl <georg@python.org>
Mon, 21 Jan 2008 17:22:06 +0000 (17:22 +0000)
Lib/formatter.py
Lib/keyword.py
Lib/urlparse.py
Tools/pynche/ColorDB.py

index fa2b38938ae6e9b228be32dad2aeb903516d920a..834b5601d30ac822bee19375b8ff9140f88b4fb6 100644 (file)
@@ -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:
index cd1d55e8a2cfea5f40a74fd98dabc427081dc294..8eb2860307e5b4bc4bd05287fbb23ae6ca6bcb11 100755 (executable)
@@ -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:
index ada61429894bbd26df9d3e0309fe68bb4f7f47dc..631a5a1cb318f3583cb4d8274269915be48628ed 100644 (file)
@@ -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
index 96b6ce67c85dd48a227d24fb55cd1c424aea9ec8..84a5b0702e00463ed9dd71cbb0af2eaa31000039 100644 (file)
@@ -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: