[Python-checkins] CVS: python/dist/src/Lib/distutils file_util.py,1.11,1.11.6.1

Michael Hudson mwh@users.sourceforge.net
Fri, 22 Feb 2002 05:22:57 -0800


Update of /cvsroot/python/python/dist/src/Lib/distutils
In directory usw-pr-cvs1:/tmp/cvs-serv15013

Modified Files:
      Tag: release22-maint
	file_util.py 
Log Message:
backport akuchling's checkin of
    revision 1.12 of file_util.py

[Bug #220993; may also fix bug #479469] Fix flakiness when old
  installations are present, by always unlinking the destination file
  before copying to it.  Without the unlink(), the copied file remains
  owned by its previous UID, causing the subsequent chmod() to fail.

Bugfix candidate, though it may cause changes on platforms where
  file ownership behaves differently.


Index: file_util.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/distutils/file_util.py,v
retrieving revision 1.11
retrieving revision 1.11.6.1
diff -C2 -d -r1.11 -r1.11.6.1
*** file_util.py	6 Dec 2001 20:51:35 -0000	1.11
--- file_util.py	22 Feb 2002 13:22:55 -0000	1.11.6.1
***************
*** 37,40 ****
--- 37,47 ----
                    "could not open '%s': %s" % (src, errstr)
  
+         if os.path.exists(dst):
+             try:
+                 os.unlink(dst)
+             except os.error, (errno, errstr):
+                 raise DistutilsFileError, \
+                       "could not delete '%s': %s" % (dst, errstr)
+         
          try:
              fdst = open(dst, 'wb')