]> granicus.if.org Git - python/commitdiff
Read the text files to be compared in universal-newline mode.
authorTim Peters <tim.peters@gmail.com>
Sun, 3 Oct 2004 19:03:19 +0000 (19:03 +0000)
committerTim Peters <tim.peters@gmail.com>
Sun, 3 Oct 2004 19:03:19 +0000 (19:03 +0000)
Misc/NEWS
Tools/scripts/diff.py
Tools/scripts/ndiff.py

index cafb04ae0efffdb9a3fce19365c9c8d55acdf13b..7927036982e4fc8d29fe42f1c5d7259410c99657 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -157,7 +157,11 @@ New platforms
 Tools/Demos
 -----------
 
-...
+- The text file comparison scripts ``ndiff.py`` and ``diff.py`` now
+  read the input files in universal-newline mode.  This spares them
+  from consuming a great deal of time to deduce the useless result that,
+  e.g., a file with Windows line ends and a file with Linux line ends
+  have no lines in common.
 
 
 What's New in Python 2.4 alpha 3?
index 05bfc2548ca798b785c371db098d1c8ff76164f5..52dcab1ff9cfe19ea6d434c7fbd5bd32a97bb7ce 100644 (file)
@@ -31,8 +31,8 @@ def main():
 
     fromdate = time.ctime(os.stat(fromfile).st_mtime)
     todate = time.ctime(os.stat(tofile).st_mtime)
-    fromlines = open(fromfile).readlines()
-    tolines = open(tofile).readlines()
+    fromlines = open(fromfile, 'U').readlines()
+    tolines = open(tofile, 'U').readlines()
 
     if options.u:
         diff = difflib.unified_diff(fromlines, tolines, fromfile, tofile, fromdate, todate, n=n)
index f399338f48a3cb185871a2c03b211bf1642b8df8..88712b8140f24e5cd5bacde2e5b007e6026fd9c8 100755 (executable)
@@ -60,7 +60,7 @@ def fail(msg):
 # couldn't be opened
 def fopen(fname):
     try:
-        return open(fname, 'r')
+        return open(fname, 'U')
     except IOError, detail:
         return fail("couldn't open " + fname + ": " + str(detail))