summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/file_util.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-01-10 16:19:56 (GMT)
committerGuido van Rossum <guido@python.org>2007-01-10 16:19:56 (GMT)
commitb940e113bf90ff71b0ef57414ea2beea9d2a4bc0 (patch)
tree0b9ea19eba1e665dac95126c3140ac2bc36326ad /Lib/distutils/file_util.py
parent893523e80a2003d4a630aafb84ba016e0070cbbd (diff)
downloadcpython-b940e113bf90ff71b0ef57414ea2beea9d2a4bc0.zip
cpython-b940e113bf90ff71b0ef57414ea2beea9d2a4bc0.tar.gz
cpython-b940e113bf90ff71b0ef57414ea2beea9d2a4bc0.tar.bz2
SF patch 1631942 by Collin Winter:
(a) "except E, V" -> "except E as V" (b) V is now limited to a simple name (local variable) (c) V is now deleted at the end of the except block
Diffstat (limited to 'Lib/distutils/file_util.py')
-rw-r--r--Lib/distutils/file_util.py23
1 files changed, 15 insertions, 8 deletions
diff --git a/Lib/distutils/file_util.py b/Lib/distutils/file_util.py
index 37b152e..c225ad3 100644
--- a/Lib/distutils/file_util.py
+++ b/Lib/distutils/file_util.py
@@ -32,27 +32,31 @@ def _copy_file_contents (src, dst, buffer_size=16*1024):
try:
try:
fsrc = open(src, 'rb')
- except os.error, (errno, errstr):
+ except os.error as e:
+ (errno, errstr) = e
raise DistutilsFileError, \
"could not open '%s': %s" % (src, errstr)
if os.path.exists(dst):
try:
os.unlink(dst)
- except os.error, (errno, errstr):
+ except os.error as e:
+ (errno, errstr) = e
raise DistutilsFileError, \
"could not delete '%s': %s" % (dst, errstr)
try:
fdst = open(dst, 'wb')
- except os.error, (errno, errstr):
+ except os.error as e:
+ (errno, errstr) = e
raise DistutilsFileError, \
"could not create '%s': %s" % (dst, errstr)
while 1:
try:
buf = fsrc.read(buffer_size)
- except os.error, (errno, errstr):
+ except os.error as e:
+ (errno, errstr) = e
raise DistutilsFileError, \
"could not read from '%s': %s" % (src, errstr)
@@ -61,7 +65,8 @@ def _copy_file_contents (src, dst, buffer_size=16*1024):
try:
fdst.write(buf)
- except os.error, (errno, errstr):
+ except os.error as e:
+ (errno, errstr) = e
raise DistutilsFileError, \
"could not write to '%s': %s" % (dst, errstr)
@@ -146,7 +151,7 @@ def copy_file (src, dst,
import macostools
try:
macostools.copy(src, dst, 0, preserve_times)
- except os.error, exc:
+ except os.error as exc:
raise DistutilsFileError, \
"could not copy '%s' to '%s': %s" % (src, dst, exc[-1])
@@ -217,7 +222,8 @@ def move_file (src, dst,
copy_it = 0
try:
os.rename(src, dst)
- except os.error, (num, msg):
+ except os.error as e:
+ (num, msg) = e
if num == errno.EXDEV:
copy_it = 1
else:
@@ -228,7 +234,8 @@ def move_file (src, dst,
copy_file(src, dst)
try:
os.unlink(src)
- except os.error, (num, msg):
+ except os.error as e:
+ (num, msg) = e
try:
os.unlink(dst)
except os.error: