diff options
author | Guido van Rossum <guido@python.org> | 1999-06-25 14:21:44 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1999-06-25 14:21:44 (GMT) |
commit | 59834f11e338f547093e07c53909676efe24062b (patch) | |
tree | f1ec989e9782d6d427a0875ae6a5af7f2ccf3e35 /Lib | |
parent | 3aa9ca147b24eb55b350f5dea9ccdf37673de044 (diff) | |
download | cpython-59834f11e338f547093e07c53909676efe24062b.zip cpython-59834f11e338f547093e07c53909676efe24062b.tar.gz cpython-59834f11e338f547093e07c53909676efe24062b.tar.bz2 |
Mikael Lyngvig writes:
I just noticed that the changes below also apply to cmpcache.py, which
is virtually identical to cmp.py.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/cmpcache.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/cmpcache.py b/Lib/cmpcache.py index 494dcc1..5446e66 100644 --- a/Lib/cmpcache.py +++ b/Lib/cmpcache.py @@ -22,14 +22,14 @@ cache = {} # Compare two files, use the cache if possible. # May raise os.error if a stat or open of either fails. # -def cmp(f1, f2): +def cmp(f1, f2, shallow=1): # Return 1 for identical files, 0 for different. # Raise exceptions if either file could not be statted, read, etc. s1, s2 = sig(statcache.stat(f1)), sig(statcache.stat(f2)) if not S_ISREG(s1[0]) or not S_ISREG(s2[0]): # Either is a not a plain file -- always report as different return 0 - if s1 == s2: + if shallow and s1 == s2: # type, size & mtime match -- report same return 1 if s1[:2] <> s2[:2]: # Types or sizes differ, don't bother @@ -59,8 +59,8 @@ def sig(st): def do_cmp(f1, f2): #print ' cmp', f1, f2 # XXX remove when debugged bufsize = 8*1024 # Could be tuned - fp1 = open(f1, 'r') - fp2 = open(f2, 'r') + fp1 = open(f1, 'rb') + fp2 = open(f2, 'rb') while 1: b1 = fp1.read(bufsize) b2 = fp2.read(bufsize) |