summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael W. Hudson <mwh@python.net>2002-02-22 13:22:55 (GMT)
committerMichael W. Hudson <mwh@python.net>2002-02-22 13:22:55 (GMT)
commit35bbe5666781d52ceb4c3190bfb35328b76a9952 (patch)
tree6008c8139fc660ede0ef478063b0ff38f7f2b5e3
parentfffbde74800513e3bde54b8c6e50739cdfef1dce (diff)
downloadcpython-35bbe5666781d52ceb4c3190bfb35328b76a9952.zip
cpython-35bbe5666781d52ceb4c3190bfb35328b76a9952.tar.gz
cpython-35bbe5666781d52ceb4c3190bfb35328b76a9952.tar.bz2
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.
-rw-r--r--Lib/distutils/file_util.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/distutils/file_util.py b/Lib/distutils/file_util.py
index 526e4cf..14772fb 100644
--- a/Lib/distutils/file_util.py
+++ b/Lib/distutils/file_util.py
@@ -36,6 +36,13 @@ def _copy_file_contents (src, dst, buffer_size=16*1024):
raise DistutilsFileError, \
"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')
except os.error, (errno, errstr):