[Python-bugs-list] [ python-Bugs-409773 ] Bug Fix In dircmp class
noreply@sourceforge.net
noreply@sourceforge.net
Tue, 20 Mar 2001 08:13:27 -0800
Bugs item #409773, was updated on 2001-03-19 09:08
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=409773&group_id=5470
Category: Python Library
Group: None
>Status: Closed
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
>Assigned to: Guido van Rossum (gvanrossum)
Summary: Bug Fix In dircmp class
Initial Comment:
Hello, I tried to diff two directories, using
filecmp.dircmp class.
I have Python2.0 installed from source in Debian
(Potato).
The code is the following:
#!/tmp/bin/python
import filecmp
from filecmp import dircmp
a = dircmp('lala','loulou')
b = a.report_full_closure()
print b
It yields:
hargikas@simula:~/src/mydiff$ ./mydiff.py
diff lala loulou
Only in loulou : ['kiko']
Traceback (most recent call last):
File "./mydiff.py", line 6, in ?
b = a.report_full_closure()
File "/tmp/lib/python2.0/filecmp.py", line 264,
in report_full_closure
self.report()
File "/tmp/lib/python2.0/filecmp.py", line 241, in
report
if self.same_files:
File "/tmp/lib/python2.0/filecmp.py", line 147, in
__getattr__
self.phase3()
File "/tmp/lib/python2.0/filecmp.py", line 214, in
phase3
xx = cmpfiles(self.left, self.right,
self.common_files)
File "/tmp/lib/python2.0/filecmp.py", line 288, in
cmpfiles
res[_cmp(ax, bx, shallow,
use_statcache)].append(x)
TypeError: too many arguments; expected 2, got 4
Actually the 288 line of filecmp.py is:
res[_cmp(ax, bx, shallow, use_statcache)].append(x)
and it should be:
res[cmp(ax, bx, shallow, use_statcache)].append(x)
NOTE the missing undescore, in the correct version.
With that changed it worked ok:
hargikas@simula:~/src/mydiff$ ./mydiff.py
diff lala loulou
Only in loulou : ['kiko']
Identical files : ['loulou']
Differing files : ['lala']
None
Any Ideas???
Best Regards,
Charalampos Gikas,
Virtual Trip LTD
http://www.vtrip-ltd.com
----------------------------------------------------------------------
>Comment By: Guido van Rossum (gvanrossum)
Date: 2001-03-20 08:13
Message:
Logged In: YES
user_id=6380
This was fixed in Python 2.1.
The fix you suggest is wrong -- it really needs to call
_cmp().
Here's the proper fix:
*** filecmp.py 2000/07/03 08:18:47 1.6
--- filecmp.py 2000/12/03 20:48:07 1.7
***************
*** 295,303 ****
# 1 for different
# 2 for funny cases (can't stat, etc.)
#
! def _cmp(a, b):
try:
! return not abs(cmp(a, b))
except os.error:
return 2
--- 295,303 ----
# 1 for different
# 2 for funny cases (can't stat, etc.)
#
! def _cmp(a, b, sh, st):
try:
! return not abs(cmp(a, b, sh, st))
except os.error:
return 2
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=409773&group_id=5470