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
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 @@
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 @@
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 @@
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 @@
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 @@
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: