[Python-checkins] python/dist/src/Lib filecmp.py,1.13,1.14

akuchling@users.sourceforge.net akuchling@users.sourceforge.net
Thu, 06 Feb 2003 09:50:03 -0800


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1:/tmp/cvs-serv12521

Modified Files:
	filecmp.py 
Log Message:
[Bug #680494] filecmp.py uses obsolete statcache module.
   Simply replace all uses of statcache with os.stat.

Should I add a DeprecationWarning triggered if the use_statcache argument 
is supplied, so we can remove it in 2.4?


Index: filecmp.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/filecmp.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** filecmp.py	2 Jun 2002 18:55:56 -0000	1.13
--- filecmp.py	6 Feb 2003 17:50:01 -0000	1.14
***************
*** 12,16 ****
  import os
  import stat
- import statcache
  
  __all__ = ["cmp","dircmp","cmpfiles"]
--- 12,15 ----
***************
*** 31,36 ****
                 defaults to 1.
  
!     use_statcache -- Do not stat() each file directly: go through
!                      the statcache module for more efficiency.
  
      Return value:
--- 30,34 ----
                 defaults to 1.
  
!     use_statcache -- obsolete argument.
  
      Return value:
***************
*** 40,53 ****
      This function uses a cache for past comparisons and the results,
      with a cache invalidation mechanism relying on stale signatures.
-     Of course, if 'use_statcache' is true, this mechanism is defeated,
-     and the cache will never grow stale.
  
      """
!     if use_statcache:
!         stat_function = statcache.stat
!     else:
!         stat_function = os.stat
!     s1 = _sig(stat_function(f1))
!     s2 = _sig(stat_function(f2))
      if s1[0] != stat.S_IFREG or s2[0] != stat.S_IFREG:
          return False
--- 38,45 ----
      This function uses a cache for past comparisons and the results,
      with a cache invalidation mechanism relying on stale signatures.
  
      """
!     s1 = _sig(os.stat(f1))
!     s2 = _sig(os.stat(f2))
      if s1[0] != stat.S_IFREG or s2[0] != stat.S_IFREG:
          return False
***************
*** 189,198 ****
              ok = 1
              try:
!                 a_stat = statcache.stat(a_path)
              except os.error, why:
                  # print 'Can\'t stat', a_path, ':', why[1]
                  ok = 0
              try:
!                 b_stat = statcache.stat(b_path)
              except os.error, why:
                  # print 'Can\'t stat', b_path, ':', why[1]
--- 181,190 ----
              ok = 1
              try:
!                 a_stat = os.stat(a_path)
              except os.error, why:
                  # print 'Can\'t stat', a_path, ':', why[1]
                  ok = 0
              try:
!                 b_stat = os.stat(b_path)
              except os.error, why:
                  # print 'Can\'t stat', b_path, ':', why[1]
***************
*** 276,280 ****
      common -- list of file names found in both directories
      shallow -- if true, do comparison based solely on stat() information
!     use_statcache -- if true, use statcache.stat() instead of os.stat()
  
      Returns a tuple of three lists:
--- 268,272 ----
      common -- list of file names found in both directories
      shallow -- if true, do comparison based solely on stat() information
!     use_statcache -- obsolete argument
  
      Returns a tuple of three lists:
***************
*** 288,292 ****
          ax = os.path.join(a, x)
          bx = os.path.join(b, x)
!         res[_cmp(ax, bx, shallow, use_statcache)].append(x)
      return res
  
--- 280,284 ----
          ax = os.path.join(a, x)
          bx = os.path.join(b, x)
!         res[_cmp(ax, bx, shallow)].append(x)
      return res
  
***************
*** 298,304 ****
  #       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
--- 290,296 ----
  #       2 for funny cases (can't stat, etc.)
  #
! def _cmp(a, b, sh):
      try:
!         return not abs(cmp(a, b, sh))
      except os.error:
          return 2