mirror of
https://github.com/python/cpython.git
synced 2025-09-19 15:10:58 +00:00
Read the text files to be compared in universal-newline mode.
This commit is contained in:
parent
ab9b32c077
commit
130e37f3e2
3 changed files with 8 additions and 4 deletions
|
@ -157,7 +157,11 @@ New platforms
|
||||||
Tools/Demos
|
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?
|
What's New in Python 2.4 alpha 3?
|
||||||
|
|
|
@ -31,8 +31,8 @@ def main():
|
||||||
|
|
||||||
fromdate = time.ctime(os.stat(fromfile).st_mtime)
|
fromdate = time.ctime(os.stat(fromfile).st_mtime)
|
||||||
todate = time.ctime(os.stat(tofile).st_mtime)
|
todate = time.ctime(os.stat(tofile).st_mtime)
|
||||||
fromlines = open(fromfile).readlines()
|
fromlines = open(fromfile, 'U').readlines()
|
||||||
tolines = open(tofile).readlines()
|
tolines = open(tofile, 'U').readlines()
|
||||||
|
|
||||||
if options.u:
|
if options.u:
|
||||||
diff = difflib.unified_diff(fromlines, tolines, fromfile, tofile, fromdate, todate, n=n)
|
diff = difflib.unified_diff(fromlines, tolines, fromfile, tofile, fromdate, todate, n=n)
|
||||||
|
|
|
@ -60,7 +60,7 @@ def fail(msg):
|
||||||
# couldn't be opened
|
# couldn't be opened
|
||||||
def fopen(fname):
|
def fopen(fname):
|
||||||
try:
|
try:
|
||||||
return open(fname, 'r')
|
return open(fname, 'U')
|
||||||
except IOError, detail:
|
except IOError, detail:
|
||||||
return fail("couldn't open " + fname + ": " + str(detail))
|
return fail("couldn't open " + fname + ": " + str(detail))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue