summaryrefslogtreecommitdiffstats
path: root/Tools/scripts/methfix.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 /Tools/scripts/methfix.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 'Tools/scripts/methfix.py')
-rwxr-xr-xTools/scripts/methfix.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/Tools/scripts/methfix.py b/Tools/scripts/methfix.py
index b81871f..11875a1 100755
--- a/Tools/scripts/methfix.py
+++ b/Tools/scripts/methfix.py
@@ -59,7 +59,7 @@ def recursedown(dirname):
bad = 0
try:
names = os.listdir(dirname)
- except os.error, msg:
+ except os.error as msg:
err('%s: cannot list directory: %r\n' % (dirname, msg))
return 1
names.sort()
@@ -80,7 +80,7 @@ def fix(filename):
## dbg('fix(%r)\n' % (filename,))
try:
f = open(filename, 'r')
- except IOError, msg:
+ except IOError as msg:
err('%s: cannot open: %r\n' % (filename, msg))
return 1
head, tail = os.path.split(filename)
@@ -117,7 +117,7 @@ def fix(filename):
if g is None:
try:
g = open(tempname, 'w')
- except IOError, msg:
+ except IOError as msg:
f.close()
err('%s: cannot create: %r\n' % (tempname, msg))
return 1
@@ -141,17 +141,17 @@ def fix(filename):
try:
statbuf = os.stat(filename)
os.chmod(tempname, statbuf[ST_MODE] & 07777)
- except os.error, msg:
+ except os.error as msg:
err('%s: warning: chmod failed (%r)\n' % (tempname, msg))
# Then make a backup of the original file as filename~
try:
os.rename(filename, filename + '~')
- except os.error, msg:
+ except os.error as msg:
err('%s: warning: backup failed (%r)\n' % (filename, msg))
# Now move the temp file to the original file
try:
os.rename(tempname, filename)
- except os.error, msg:
+ except os.error as msg:
err('%s: rename failed (%r)\n' % (filename, msg))
return 1
# Return succes