This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Bug Fix In dircmp class
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: gvanrossum Nosy List: gvanrossum
Priority: normal Keywords:

Created on 2001-03-19 17:08 by anonymous, last changed 2022-04-10 16:03 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
filecmp.py nobody, 2001-03-19 17:08 The patched version of filecmp.py
Messages (2)
msg3965 - (view) Author: Nobody/Anonymous (nobody) Date: 2001-03-19 17:08
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
msg3966 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2001-03-20 16:13
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
  
History
Date User Action Args
2022-04-10 16:03:52adminsetgithub: 34190
2001-03-19 17:08:11anonymouscreate