Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 130e37f

Browse files
committed
Read the text files to be compared in universal-newline mode.
1 parent ab9b32c commit 130e37f

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

Misc/NEWS

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,11 @@ New platforms
157157
Tools/Demos
158158
-----------
159159

160-
...
160+
- The text file comparison scripts ``ndiff.py`` and ``diff.py`` now
161+
read the input files in universal-newline mode. This spares them
162+
from consuming a great deal of time to deduce the useless result that,
163+
e.g., a file with Windows line ends and a file with Linux line ends
164+
have no lines in common.
161165

162166

163167
What's New in Python 2.4 alpha 3?

Tools/scripts/diff.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ def main():
3131

3232
fromdate = time.ctime(os.stat(fromfile).st_mtime)
3333
todate = time.ctime(os.stat(tofile).st_mtime)
34-
fromlines = open(fromfile).readlines()
35-
tolines = open(tofile).readlines()
34+
fromlines = open(fromfile, 'U').readlines()
35+
tolines = open(tofile, 'U').readlines()
3636

3737
if options.u:
3838
diff = difflib.unified_diff(fromlines, tolines, fromfile, tofile, fromdate, todate, n=n)

Tools/scripts/ndiff.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def fail(msg):
6060
# couldn't be opened
6161
def fopen(fname):
6262
try:
63-
return open(fname, 'r')
63+
return open(fname, 'U')
6464
except IOError, detail:
6565
return fail("couldn't open " + fname + ": " + str(detail))
6666

0 commit comments

Comments
 (0)