[Python-checkins] cpython (merge 3.2 -> 3.2): Branch merge

eric.araujo python-checkins at python.org
Fri Aug 12 19:56:03 CEST 2011


http://hg.python.org/cpython/rev/d04a31a43a15
changeset:   71843:d04a31a43a15
branch:      3.2
parent:      71838:aa6c073c2597
parent:      71840:47ffb957921d
user:        Éric Araujo <merwok at netwok.org>
date:        Fri Aug 12 19:52:43 2011 +0200
summary:
  Branch merge

files:
  Tools/scripts/crlf.py |  12 ++++++------
  Tools/scripts/lfcr.py |  12 ++++++------
  2 files changed, 12 insertions(+), 12 deletions(-)


diff --git a/Tools/scripts/crlf.py b/Tools/scripts/crlf.py
--- a/Tools/scripts/crlf.py
+++ b/Tools/scripts/crlf.py
@@ -8,16 +8,16 @@
         if os.path.isdir(filename):
             print(filename, "Directory!")
             continue
-        data = open(filename, "rb").read()
-        if '\0' in data:
+        with open(filename, "rb") as f:
+            data = f.read()
+        if b'\0' in data:
             print(filename, "Binary!")
             continue
-        newdata = data.replace("\r\n", "\n")
+        newdata = data.replace(b"\r\n", b"\n")
         if newdata != data:
             print(filename)
-            f = open(filename, "wb")
-            f.write(newdata)
-            f.close()
+            with open(filename, "wb") as f:
+                f.write(newdata)
 
 if __name__ == '__main__':
     main()
diff --git a/Tools/scripts/lfcr.py b/Tools/scripts/lfcr.py
--- a/Tools/scripts/lfcr.py
+++ b/Tools/scripts/lfcr.py
@@ -9,16 +9,16 @@
         if os.path.isdir(filename):
             print(filename, "Directory!")
             continue
-        data = open(filename, "rb").read()
-        if '\0' in data:
+        with open(filename, "rb") as f:
+            data = f.read()
+        if b'\0' in data:
             print(filename, "Binary!")
             continue
-        newdata = re.sub("\r?\n", "\r\n", data)
+        newdata = re.sub(b"\r?\n", b"\r\n", data)
         if newdata != data:
             print(filename)
-            f = open(filename, "wb")
-            f.write(newdata)
-            f.close()
+            with open(filename, "wb") as f:
+                f.write(newdata)
 
 if __name__ == '__main__':
     main()

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list