summaryrefslogtreecommitdiffstats
path: root/Tools
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
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')
-rwxr-xr-xTools/audiopy/audiopy5
-rw-r--r--Tools/bgen/bgen/scantools.py6
-rw-r--r--Tools/compiler/compile.py2
-rw-r--r--Tools/compiler/regrtest.py2
-rwxr-xr-xTools/faqwiz/faqw.py2
-rw-r--r--Tools/faqwiz/faqwiz.py10
-rw-r--r--Tools/freeze/checkextensions_win32.py2
-rwxr-xr-xTools/freeze/freeze.py8
-rwxr-xr-xTools/i18n/msgfmt.py6
-rwxr-xr-xTools/i18n/pygettext.py4
-rw-r--r--Tools/pybench/CommandLine.py4
-rwxr-xr-xTools/pybench/pybench.py8
-rw-r--r--Tools/pynche/Main.py2
-rwxr-xr-xTools/scripts/byext.py4
-rwxr-xr-xTools/scripts/byteyears.py2
-rwxr-xr-xTools/scripts/checkappend.py6
-rwxr-xr-xTools/scripts/classfix.py12
-rw-r--r--Tools/scripts/cleanfuture.py4
-rwxr-xr-xTools/scripts/cvsfiles.py2
-rwxr-xr-xTools/scripts/dutree.py2
-rwxr-xr-xTools/scripts/finddiv.py6
-rwxr-xr-xTools/scripts/findlinksto.py2
-rwxr-xr-xTools/scripts/findnocoding.py2
-rwxr-xr-xTools/scripts/fixcid.py16
-rwxr-xr-xTools/scripts/fixdiv.py6
-rwxr-xr-xTools/scripts/fixheader.py4
-rwxr-xr-xTools/scripts/fixnotice.py2
-rwxr-xr-xTools/scripts/fixps.py2
-rwxr-xr-xTools/scripts/ftpmirror.py20
-rwxr-xr-xTools/scripts/linktree.py6
-rwxr-xr-xTools/scripts/logmerge.py2
-rw-r--r--Tools/scripts/md5sum.py6
-rwxr-xr-xTools/scripts/methfix.py12
-rwxr-xr-xTools/scripts/ndiff.py4
-rwxr-xr-xTools/scripts/pathfix.py14
-rwxr-xr-xTools/scripts/pindent.py2
-rw-r--r--Tools/scripts/pysource.py6
-rw-r--r--Tools/scripts/redemo.py2
-rw-r--r--Tools/scripts/reindent.py4
-rwxr-xr-xTools/scripts/rgrep.py4
-rwxr-xr-xTools/scripts/texi2html.py10
-rwxr-xr-xTools/scripts/treesync.py2
-rwxr-xr-xTools/scripts/untabify.py4
-rw-r--r--Tools/unicode/comparecodecs.py4
-rw-r--r--Tools/unicode/gencodec.py6
-rw-r--r--Tools/unicode/listcodecs.py2
-rw-r--r--Tools/versioncheck/pyversioncheck.py2
-rwxr-xr-xTools/webchecker/wcgui.py2
-rwxr-xr-xTools/webchecker/webchecker.py10
-rwxr-xr-xTools/webchecker/websucker.py4
50 files changed, 131 insertions, 130 deletions
diff --git a/Tools/audiopy/audiopy b/Tools/audiopy/audiopy
index b817c5c..869d87a 100755
--- a/Tools/audiopy/audiopy
+++ b/Tools/audiopy/audiopy
@@ -309,7 +309,7 @@ Email: bwarsaw@python.org''' % __version__)
info.o_gain = self.__scalevar.get()
try:
self.__devctl.setinfo(info)
- except sunaudiodev.error, msg:
+ except sunaudiodev.error as msg:
# TBD: what to do? it's probably temporary.
pass
@@ -496,7 +496,8 @@ Version: %s''' % __version__
# now set the values
try:
device.setinfo(info)
- except sunaudiodev.error, (code, msg):
+ except sunaudiodev.error as e:
+ (code, msg) = e
if code <> errno.EINVAL:
raise
device.close()
diff --git a/Tools/bgen/bgen/scantools.py b/Tools/bgen/bgen/scantools.py
index d809a65..bae29a0 100644
--- a/Tools/bgen/bgen/scantools.py
+++ b/Tools/bgen/bgen/scantools.py
@@ -293,7 +293,7 @@ if missing: raise "Missing Types"
def openrepairfile(self, filename = "REPAIR"):
try:
return open(filename, "rU")
- except IOError, msg:
+ except IOError as msg:
print repr(filename), ":", msg
print "Cannot open repair file -- assume no repair needed"
return None
@@ -419,7 +419,7 @@ if missing: raise "Missing Types"
def openoutput(self, filename):
try:
file = open(filename, 'w')
- except IOError, arg:
+ except IOError as arg:
raise IOError, (filename, arg)
self.setfiletype(filename)
return file
@@ -460,7 +460,7 @@ if missing: raise "Missing Types"
# If not on the path, or absolute, try default open()
try:
return open(filename, 'rU')
- except IOError, arg:
+ except IOError as arg:
raise IOError, (arg, filename)
def getline(self):
diff --git a/Tools/compiler/compile.py b/Tools/compiler/compile.py
index 9d50425..51a9f0c 100644
--- a/Tools/compiler/compile.py
+++ b/Tools/compiler/compile.py
@@ -40,7 +40,7 @@ def main():
else:
compileFile(filename, DISPLAY)
- except SyntaxError, err:
+ except SyntaxError as err:
print err
if err.lineno is not None:
print err.lineno
diff --git a/Tools/compiler/regrtest.py b/Tools/compiler/regrtest.py
index 4244d62..d86d746 100644
--- a/Tools/compiler/regrtest.py
+++ b/Tools/compiler/regrtest.py
@@ -42,7 +42,7 @@ def compile_files(dir):
print file,
try:
compileFile(source)
- except SyntaxError, err:
+ except SyntaxError as err:
print err
continue
# make sure the .pyc file is not over-written
diff --git a/Tools/faqwiz/faqw.py b/Tools/faqwiz/faqw.py
index a26e0d6..06db125 100755
--- a/Tools/faqwiz/faqw.py
+++ b/Tools/faqwiz/faqw.py
@@ -24,7 +24,7 @@ try:
os.chdir(FAQDIR)
sys.path.insert(0, SRCDIR)
import faqwiz
-except SystemExit, n:
+except SystemExit as n:
sys.exit(n)
except:
t, v, tb = sys.exc_info()
diff --git a/Tools/faqwiz/faqwiz.py b/Tools/faqwiz/faqwiz.py
index bdd270c..d8b8cd5 100644
--- a/Tools/faqwiz/faqwiz.py
+++ b/Tools/faqwiz/faqwiz.py
@@ -348,7 +348,7 @@ class FaqDir:
raise InvalidFile(file)
try:
fp = open(file)
- except IOError, msg:
+ except IOError as msg:
raise NoSuchFile(file, msg)
try:
return self.entryclass(fp, file, sec_num)
@@ -387,11 +387,11 @@ class FaqWizard:
else:
try:
meth()
- except InvalidFile, exc:
+ except InvalidFile as exc:
self.error("Invalid entry file name %s" % exc.file)
- except NoSuchFile, exc:
+ except NoSuchFile as exc:
self.error("No entry with file name %s" % exc.file)
- except NoSuchSection, exc:
+ except NoSuchSection as exc:
self.error("No section number %s" % exc.section)
self.epilogue()
@@ -796,7 +796,7 @@ class FaqWizard:
pass
try:
f = open(file, 'w')
- except IOError, why:
+ except IOError as why:
self.error(CANTWRITE, file=file, why=why)
return
date = time.ctime(now)
diff --git a/Tools/freeze/checkextensions_win32.py b/Tools/freeze/checkextensions_win32.py
index a198ecf..ba3853c 100644
--- a/Tools/freeze/checkextensions_win32.py
+++ b/Tools/freeze/checkextensions_win32.py
@@ -131,7 +131,7 @@ def parse_dsp(dsp):
dsp_path, dsp_name = os.path.split(dsp)
try:
lines = open(dsp, "r").readlines()
- except IOError, msg:
+ except IOError as msg:
sys.stderr.write("%s: %s\n" % (dsp, msg))
return None
for line in lines:
diff --git a/Tools/freeze/freeze.py b/Tools/freeze/freeze.py
index 3e6a580..786d53a 100755
--- a/Tools/freeze/freeze.py
+++ b/Tools/freeze/freeze.py
@@ -145,7 +145,7 @@ def main():
if sys.argv[pos] == '-i':
try:
options = open(sys.argv[pos+1]).read().split()
- except IOError, why:
+ except IOError as why:
usage("File name '%s' specified with the -i option "
"can not be read - %s" % (sys.argv[pos+1], why) )
# Replace the '-i' and the filename with the read params.
@@ -156,7 +156,7 @@ def main():
# Now parse the command line with the extras inserted.
try:
opts, args = getopt.getopt(sys.argv[1:], 'r:a:dEe:hmo:p:P:qs:wX:x:l:')
- except getopt.error, msg:
+ except getopt.error as msg:
usage('getopt error: ' + str(msg))
# proces option arguments
@@ -311,7 +311,7 @@ def main():
try:
os.mkdir(odir)
print "Created output directory", odir
- except os.error, msg:
+ except os.error as msg:
usage('%s: mkdir failed (%s)' % (odir, str(msg)))
base = ''
if odir:
@@ -333,7 +333,7 @@ def main():
try:
custom_entry_point, python_entry_is_main = \
winmakemakefile.get_custom_entry_point(subsystem)
- except ValueError, why:
+ except ValueError as why:
usage(why)
diff --git a/Tools/i18n/msgfmt.py b/Tools/i18n/msgfmt.py
index 6433131..353be8b 100755
--- a/Tools/i18n/msgfmt.py
+++ b/Tools/i18n/msgfmt.py
@@ -110,7 +110,7 @@ def make(filename, outfile):
try:
lines = open(infile).readlines()
- except IOError, msg:
+ except IOError as msg:
print >> sys.stderr, msg
sys.exit(1)
@@ -167,7 +167,7 @@ def make(filename, outfile):
try:
open(outfile,"wb").write(output)
- except IOError,msg:
+ except IOError as msg:
print >> sys.stderr, msg
@@ -176,7 +176,7 @@ def main():
try:
opts, args = getopt.getopt(sys.argv[1:], 'hVo:',
['help', 'version', 'output-file='])
- except getopt.error, msg:
+ except getopt.error as msg:
usage(1, msg)
outfile = None
diff --git a/Tools/i18n/pygettext.py b/Tools/i18n/pygettext.py
index eadd149..24f1ce1 100755
--- a/Tools/i18n/pygettext.py
+++ b/Tools/i18n/pygettext.py
@@ -512,7 +512,7 @@ def main():
'style=', 'verbose', 'version', 'width=', 'exclude-file=',
'docstrings', 'no-docstrings',
])
- except getopt.error, msg:
+ except getopt.error as msg:
usage(1, msg)
# for holding option values
@@ -635,7 +635,7 @@ def main():
eater.set_filename(filename)
try:
tokenize.tokenize(fp.readline, eater)
- except tokenize.TokenError, e:
+ except tokenize.TokenError as e:
print >> sys.stderr, '%s: %s, line %d, column %d' % (
e[0], filename, e[1][0], e[1][1])
finally:
diff --git a/Tools/pybench/CommandLine.py b/Tools/pybench/CommandLine.py
index 6601be5..ddf958d 100644
--- a/Tools/pybench/CommandLine.py
+++ b/Tools/pybench/CommandLine.py
@@ -347,7 +347,7 @@ class Application:
if rc is None:
rc = 0
- except SystemExit,rc:
+ except SystemExit as rc:
pass
except KeyboardInterrupt:
@@ -433,7 +433,7 @@ class Application:
files = l
self.optionlist = optlist
self.files = files + self.files
- except getopt.error,why:
+ except getopt.error as why:
self.help(why)
sys.exit(1)
diff --git a/Tools/pybench/pybench.py b/Tools/pybench/pybench.py
index 392ff50..e0ff732 100755
--- a/Tools/pybench/pybench.py
+++ b/Tools/pybench/pybench.py
@@ -865,7 +865,7 @@ python pybench.py -s p25.pybench -c p21.pybench
bench.name = compare_to
f.close()
compare_to = bench
- except IOError, reason:
+ except IOError as reason:
print '* Error opening/reading file %s: %s' % (
repr(compare_to),
reason)
@@ -885,7 +885,7 @@ python pybench.py -s p25.pybench -c p21.pybench
else:
bench.print_benchmark(hidenoise=hidenoise,
limitnames=limitnames)
- except IOError, reason:
+ except IOError as reason:
print '* Error opening/reading file %s: %s' % (
repr(show_bench),
reason)
@@ -931,9 +931,9 @@ python pybench.py -s p25.pybench -c p21.pybench
bench.name = reportfile
pickle.dump(bench,f)
f.close()
- except IOError, reason:
+ except IOError as reason:
print '* Error opening/writing reportfile'
- except IOError, reason:
+ except IOError as reason:
print '* Error opening/writing reportfile %s: %s' % (
reportfile,
reason)
diff --git a/Tools/pynche/Main.py b/Tools/pynche/Main.py
index 1fa3f17..a0a2d81 100644
--- a/Tools/pynche/Main.py
+++ b/Tools/pynche/Main.py
@@ -186,7 +186,7 @@ def main():
sys.argv[1:],
'hd:i:Xv',
['database=', 'initfile=', 'ignore', 'help', 'version'])
- except getopt.error, msg:
+ except getopt.error as msg:
usage(1, msg)
if len(args) == 0:
diff --git a/Tools/scripts/byext.py b/Tools/scripts/byext.py
index 09610b0..998b4c0 100755
--- a/Tools/scripts/byext.py
+++ b/Tools/scripts/byext.py
@@ -24,7 +24,7 @@ class Stats:
self.addstats("<dir>", "dirs", 1)
try:
names = os.listdir(dir)
- except os.error, err:
+ except os.error as err:
sys.stderr.write("Can't list %s: %s\n" % (dir, err))
self.addstats("<dir>", "unlistable", 1)
return
@@ -53,7 +53,7 @@ class Stats:
self.addstats(ext, "files", 1)
try:
f = open(filename, "rb")
- except IOError, err:
+ except IOError as err:
sys.stderr.write("Can't open %s: %s\n" % (filename, err))
self.addstats(ext, "unopenable", 1)
return
diff --git a/Tools/scripts/byteyears.py b/Tools/scripts/byteyears.py
index ba38caf..b4d4335 100755
--- a/Tools/scripts/byteyears.py
+++ b/Tools/scripts/byteyears.py
@@ -43,7 +43,7 @@ def main():
for filename in sys.argv[1:]:
try:
st = statfunc(filename)
- except os.error, msg:
+ except os.error as msg:
sys.stderr.write("can't stat %r: %r\n" % (filename, msg))
status = 1
st = ()
diff --git a/Tools/scripts/checkappend.py b/Tools/scripts/checkappend.py
index a8714d9..2025ba9 100755
--- a/Tools/scripts/checkappend.py
+++ b/Tools/scripts/checkappend.py
@@ -50,7 +50,7 @@ def main():
global verbose
try:
opts, args = getopt.getopt(sys.argv[1:], "v")
- except getopt.error, msg:
+ except getopt.error as msg:
errprint(str(msg) + "\n\n" + __doc__)
return
for opt, optarg in opts:
@@ -77,7 +77,7 @@ def check(file):
try:
f = open(file)
- except IOError, msg:
+ except IOError as msg:
errprint("%r: I/O Error: %s" % (file, msg))
return
@@ -104,7 +104,7 @@ class AppendChecker:
def run(self):
try:
tokenize.tokenize(self.file.readline, self.tokeneater)
- except tokenize.TokenError, msg:
+ except tokenize.TokenError as msg:
errprint("%r: Token Error: %s" % (self.fname, msg))
self.nerrors = self.nerrors + 1
return self.nerrors == 0
diff --git a/Tools/scripts/classfix.py b/Tools/scripts/classfix.py
index d30700f..f65e630 100755
--- a/Tools/scripts/classfix.py
+++ b/Tools/scripts/classfix.py
@@ -62,7 +62,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()
@@ -83,7 +83,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)
@@ -106,7 +106,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
@@ -130,17 +130,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
diff --git a/Tools/scripts/cleanfuture.py b/Tools/scripts/cleanfuture.py
index 3f2da3a..0e90cd3 100644
--- a/Tools/scripts/cleanfuture.py
+++ b/Tools/scripts/cleanfuture.py
@@ -59,7 +59,7 @@ def main():
global verbose, recurse, dryrun
try:
opts, args = getopt.getopt(sys.argv[1:], "drv")
- except getopt.error, msg:
+ except getopt.error as msg:
errprint(msg)
return
for o, a in opts:
@@ -92,7 +92,7 @@ def check(file):
print "checking", file, "...",
try:
f = open(file)
- except IOError, msg:
+ except IOError as msg:
errprint("%r: I/O Error: %s" % (file, str(msg)))
return
diff --git a/Tools/scripts/cvsfiles.py b/Tools/scripts/cvsfiles.py
index 53b4294..eac5945 100755
--- a/Tools/scripts/cvsfiles.py
+++ b/Tools/scripts/cvsfiles.py
@@ -20,7 +20,7 @@ cutofftime = 0
def main():
try:
opts, args = getopt.getopt(sys.argv[1:], "n:")
- except getopt.error, msg:
+ except getopt.error as msg:
print msg
print __doc__,
return 1
diff --git a/Tools/scripts/dutree.py b/Tools/scripts/dutree.py
index d938ae1..c9f6ea8 100755
--- a/Tools/scripts/dutree.py
+++ b/Tools/scripts/dutree.py
@@ -18,7 +18,7 @@ def main():
total, d = store(size, comps, total, d)
try:
display(total, d)
- except IOError, e:
+ except IOError as e:
if e.errno != errno.EPIPE:
raise
diff --git a/Tools/scripts/finddiv.py b/Tools/scripts/finddiv.py
index 97f6331..8fdc52b 100755
--- a/Tools/scripts/finddiv.py
+++ b/Tools/scripts/finddiv.py
@@ -23,7 +23,7 @@ import tokenize
def main():
try:
opts, args = getopt.getopt(sys.argv[1:], "lh")
- except getopt.error, msg:
+ except getopt.error as msg:
usage(msg)
return 2
if not args:
@@ -52,7 +52,7 @@ def process(filename, listnames):
return processdir(filename, listnames)
try:
fp = open(filename)
- except IOError, msg:
+ except IOError as msg:
sys.stderr.write("Can't open: %s\n" % msg)
return 1
g = tokenize.generate_tokens(fp.readline)
@@ -70,7 +70,7 @@ def process(filename, listnames):
def processdir(dir, listnames):
try:
names = os.listdir(dir)
- except os.error, msg:
+ except os.error as msg:
sys.stderr.write("Can't list directory: %s\n" % dir)
return 1
files = []
diff --git a/Tools/scripts/findlinksto.py b/Tools/scripts/findlinksto.py
index 8dd4bfb..f23316d 100755
--- a/Tools/scripts/findlinksto.py
+++ b/Tools/scripts/findlinksto.py
@@ -14,7 +14,7 @@ def main():
opts, args = getopt.getopt(sys.argv[1:], '')
if len(args) < 2:
raise getopt.GetoptError('not enough arguments', None)
- except getopt.GetoptError, msg:
+ except getopt.GetoptError as msg:
sys.stdout = sys.stderr
print msg
print 'usage: findlinksto pattern directory ...'
diff --git a/Tools/scripts/findnocoding.py b/Tools/scripts/findnocoding.py
index 537f0a1..28a299a 100755
--- a/Tools/scripts/findnocoding.py
+++ b/Tools/scripts/findnocoding.py
@@ -78,7 +78,7 @@ usage = """Usage: %s [-cd] paths...
try:
opts, args = getopt.getopt(sys.argv[1:], 'cd')
-except getopt.error, msg:
+except getopt.error as msg:
print >>sys.stderr, msg
print >>sys.stderr, usage
sys.exit(1)
diff --git a/Tools/scripts/fixcid.py b/Tools/scripts/fixcid.py
index 433a425..29e0e10 100755
--- a/Tools/scripts/fixcid.py
+++ b/Tools/scripts/fixcid.py
@@ -62,7 +62,7 @@ def usage():
def main():
try:
opts, args = getopt.getopt(sys.argv[1:], 'crs:')
- except getopt.error, msg:
+ except getopt.error as msg:
err('Options error: ' + str(msg) + '\n')
usage()
sys.exit(2)
@@ -97,7 +97,7 @@ def recursedown(dirname):
bad = 0
try:
names = os.listdir(dirname)
- except os.error, msg:
+ except os.error as msg:
err(dirname + ': cannot list directory: ' + str(msg) + '\n')
return 1
names.sort()
@@ -124,7 +124,7 @@ def fix(filename):
# File replacement mode
try:
f = open(filename, 'r')
- except IOError, msg:
+ except IOError as msg:
err(filename + ': cannot open: ' + str(msg) + '\n')
return 1
head, tail = os.path.split(filename)
@@ -148,7 +148,7 @@ def fix(filename):
if g is None:
try:
g = open(tempname, 'w')
- except IOError, msg:
+ except IOError as msg:
f.close()
err(tempname+': cannot create: '+
str(msg)+'\n')
@@ -175,17 +175,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(tempname + ': warning: chmod failed (' + str(msg) + ')\n')
# 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(filename + ': warning: backup failed (' + str(msg) + ')\n')
# Now move the temp file to the original file
try:
os.rename(tempname, filename)
- except os.error, msg:
+ except os.error as msg:
err(filename + ': rename failed (' + str(msg) + ')\n')
return 1
# Return succes
@@ -276,7 +276,7 @@ NotInComment = {}
def addsubst(substfile):
try:
fp = open(substfile, 'r')
- except IOError, msg:
+ except IOError as msg:
err(substfile + ': cannot read substfile: ' + str(msg) + '\n')
sys.exit(1)
lineno = 0
diff --git a/Tools/scripts/fixdiv.py b/Tools/scripts/fixdiv.py
index b2cab88..98b8a81 100755
--- a/Tools/scripts/fixdiv.py
+++ b/Tools/scripts/fixdiv.py
@@ -140,7 +140,7 @@ multi_ok = 0
def main():
try:
opts, args = getopt.getopt(sys.argv[1:], "hm")
- except getopt.error, msg:
+ except getopt.error as msg:
usage(msg)
return 2
for o, a in opts:
@@ -181,7 +181,7 @@ def readwarnings(warningsfile):
prog = re.compile(PATTERN)
try:
f = open(warningsfile)
- except IOError, msg:
+ except IOError as msg:
sys.stderr.write("can't open: %s\n" % msg)
return
warnings = {}
@@ -207,7 +207,7 @@ def process(filename, list):
assert list # if this fails, readwarnings() is broken
try:
fp = open(filename)
- except IOError, msg:
+ except IOError as msg:
sys.stderr.write("can't open: %s\n" % msg)
return 1
print "Index:", filename
diff --git a/Tools/scripts/fixheader.py b/Tools/scripts/fixheader.py
index 1bf5c52..8e8ac59 100755
--- a/Tools/scripts/fixheader.py
+++ b/Tools/scripts/fixheader.py
@@ -12,7 +12,7 @@ def main():
def process(filename):
try:
f = open(filename, 'r')
- except IOError, msg:
+ except IOError as msg:
sys.stderr.write('%s: can\'t open: %s\n' % (filename, str(msg)))
return
data = f.read()
@@ -22,7 +22,7 @@ def process(filename):
return
try:
f = open(filename, 'w')
- except IOError, msg:
+ except IOError as msg:
sys.stderr.write('%s: can\'t write: %s\n' % (filename, str(msg)))
return
sys.stderr.write('Processing %s ...\n' % filename)
diff --git a/Tools/scripts/fixnotice.py b/Tools/scripts/fixnotice.py
index 0ae4872..eedf5ba 100755
--- a/Tools/scripts/fixnotice.py
+++ b/Tools/scripts/fixnotice.py
@@ -62,7 +62,7 @@ def main():
opts, args = getopt.getopt(sys.argv[1:], 'hv',
['help', 'oldnotice=', 'newnotice=',
'dry-run', 'verbose'])
- except getopt.error, msg:
+ except getopt.error as msg:
usage(1, msg)
for opt, arg in opts:
diff --git a/Tools/scripts/fixps.py b/Tools/scripts/fixps.py
index 2ff15f4..c858e59 100755
--- a/Tools/scripts/fixps.py
+++ b/Tools/scripts/fixps.py
@@ -11,7 +11,7 @@ def main():
for filename in sys.argv[1:]:
try:
f = open(filename, 'r')
- except IOError, msg:
+ except IOError as msg:
print filename, ': can\'t open :', msg
continue
line = f.readline()
diff --git a/Tools/scripts/ftpmirror.py b/Tools/scripts/ftpmirror.py
index caade16..39ef18e 100755
--- a/Tools/scripts/ftpmirror.py
+++ b/Tools/scripts/ftpmirror.py
@@ -45,7 +45,7 @@ def main():
global verbose, interactive, mac, rmok, nologin
try:
opts, args = getopt.getopt(sys.argv[1:], 'a:bil:mnp:qrs:v')
- except getopt.error, msg:
+ except getopt.error as msg:
usage(msg)
login = ''
passwd = ''
@@ -108,13 +108,13 @@ def mirrorsubdir(f, localdir):
if verbose: print 'Creating local directory', repr(localdir)
try:
makedir(localdir)
- except os.error, msg:
+ except os.error as msg:
print "Failed to establish local directory", repr(localdir)
return
infofilename = os.path.join(localdir, '.mirrorinfo')
try:
text = open(infofilename, 'r').read()
- except IOError, msg:
+ except IOError as msg:
text = '{}'
try:
info = eval(text)
@@ -190,13 +190,13 @@ def mirrorsubdir(f, localdir):
print "Creating symlink %r -> %r" % (filename, linkto)
try:
os.symlink(linkto, tempname)
- except IOError, msg:
+ except IOError as msg:
print "Can't create %r: %s" % (tempname, msg)
continue
else:
try:
fp = open(tempname, 'wb')
- except IOError, msg:
+ except IOError as msg:
print "Can't create %r: %s" % (tempname, msg)
continue
if verbose:
@@ -209,7 +209,7 @@ def mirrorsubdir(f, localdir):
try:
f.retrbinary('RETR ' + filename,
fp1.write, 8*1024)
- except ftplib.error_perm, msg:
+ except ftplib.error_perm as msg:
print msg
t1 = time.time()
bytes = fp.tell()
@@ -222,7 +222,7 @@ def mirrorsubdir(f, localdir):
pass # Ignore the error
try:
os.rename(tempname, fullname)
- except os.error, msg:
+ except os.error as msg:
print "Can't rename %r to %r: %s" % (tempname, fullname, msg)
continue
info[filename] = infostuff
@@ -292,7 +292,7 @@ def mirrorsubdir(f, localdir):
print 'Remote cwd', repr(subdir)
try:
f.cwd(subdir)
- except ftplib.error_perm, msg:
+ except ftplib.error_perm as msg:
print "Can't chdir to", repr(subdir), ":", repr(msg)
else:
if verbose: print 'Mirroring as', repr(localsubdir)
@@ -322,13 +322,13 @@ def remove(fullname):
return 0
try:
os.rmdir(fullname)
- except os.error, msg:
+ except os.error as msg:
print "Can't remove local directory %r: %s" % (fullname, msg)
return 0
else:
try:
os.unlink(fullname)
- except os.error, msg:
+ except os.error as msg:
print "Can't remove local file %r: %s" % (fullname, msg)
return 0
return 1
diff --git a/Tools/scripts/linktree.py b/Tools/scripts/linktree.py
index 995f2ef..7f17046 100755
--- a/Tools/scripts/linktree.py
+++ b/Tools/scripts/linktree.py
@@ -32,13 +32,13 @@ def main():
return 1
try:
os.mkdir(newtree, 0777)
- except os.error, msg:
+ except os.error as msg:
print newtree + ': cannot mkdir:', msg
return 1
linkname = os.path.join(newtree, link)
try:
os.symlink(os.path.join(os.pardir, oldtree), linkname)
- except os.error, msg:
+ except os.error as msg:
if not link_may_fail:
print linkname + ': cannot symlink:', msg
return 1
@@ -51,7 +51,7 @@ def linknames(old, new, link):
if debug: print 'linknames', (old, new, link)
try:
names = os.listdir(old)
- except os.error, msg:
+ except os.error as msg:
print old + ': warning: cannot listdir:', msg
return
for name in names:
diff --git a/Tools/scripts/logmerge.py b/Tools/scripts/logmerge.py
index edfec2c..d07dfc6 100755
--- a/Tools/scripts/logmerge.py
+++ b/Tools/scripts/logmerge.py
@@ -180,6 +180,6 @@ def format_output(database):
if __name__ == '__main__':
try:
main()
- except IOError, e:
+ except IOError as e:
if e.errno != errno.EPIPE:
raise
diff --git a/Tools/scripts/md5sum.py b/Tools/scripts/md5sum.py
index e045f1a..140c0b3 100644
--- a/Tools/scripts/md5sum.py
+++ b/Tools/scripts/md5sum.py
@@ -43,7 +43,7 @@ def sum(*files):
def printsum(filename, out=sys.stdout):
try:
fp = open(filename, rmode)
- except IOError, msg:
+ except IOError as msg:
sys.stderr.write('%s: Can\'t open: %s\n' % (filename, msg))
return 1
if fnfilter:
@@ -60,7 +60,7 @@ def printsumfp(fp, filename, out=sys.stdout):
if not data:
break
m.update(data)
- except IOError, msg:
+ except IOError as msg:
sys.stderr.write('%s: I/O error: %s\n' % (filename, msg))
return 1
out.write('%s %s\n' % (m.hexdigest(), filename))
@@ -70,7 +70,7 @@ def main(args = sys.argv[1:], out=sys.stdout):
global fnfilter, rmode, bufsize
try:
opts, args = getopt.getopt(args, 'blts:')
- except getopt.error, msg:
+ except getopt.error as msg:
sys.stderr.write('%s: %s\n%s' % (sys.argv[0], msg, usage))
return 2
for o, a in opts:
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
diff --git a/Tools/scripts/ndiff.py b/Tools/scripts/ndiff.py
index 88712b8..2afc132 100755
--- a/Tools/scripts/ndiff.py
+++ b/Tools/scripts/ndiff.py
@@ -61,7 +61,7 @@ def fail(msg):
def fopen(fname):
try:
return open(fname, 'U')
- except IOError, detail:
+ except IOError as detail:
return fail("couldn't open " + fname + ": " + str(detail))
# open two files & spray the diff to stdout; return false iff a problem
@@ -85,7 +85,7 @@ def main(args):
import getopt
try:
opts, args = getopt.getopt(args, "qr:")
- except getopt.error, detail:
+ except getopt.error as detail:
return fail(str(detail))
noisy = 1
qseen = rseen = 0
diff --git a/Tools/scripts/pathfix.py b/Tools/scripts/pathfix.py
index 7f6f191..c59c0f2 100755
--- a/Tools/scripts/pathfix.py
+++ b/Tools/scripts/pathfix.py
@@ -37,7 +37,7 @@ def main():
sys.argv[0])
try:
opts, args = getopt.getopt(sys.argv[1:], 'i:')
- except getopt.error, msg:
+ except getopt.error as msg:
err(msg + '\n')
err(usage)
sys.exit(2)
@@ -68,7 +68,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()
@@ -89,7 +89,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
line = f.readline()
@@ -102,7 +102,7 @@ def fix(filename):
tempname = os.path.join(head, '@' + tail)
try:
g = open(tempname, 'w')
- except IOError, msg:
+ except IOError as msg:
f.close()
err('%s: cannot create: %r\n' % (tempname, msg))
return 1
@@ -122,17 +122,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
diff --git a/Tools/scripts/pindent.py b/Tools/scripts/pindent.py
index 89ed9e6..9f444f2 100755
--- a/Tools/scripts/pindent.py
+++ b/Tools/scripts/pindent.py
@@ -491,7 +491,7 @@ def test():
import getopt
try:
opts, args = getopt.getopt(sys.argv[1:], 'cdrs:t:e')
- except getopt.error, msg:
+ except getopt.error as msg:
sys.stderr.write('Error: %s\n' % msg)
sys.stderr.write(usage)
sys.exit(2)
diff --git a/Tools/scripts/pysource.py b/Tools/scripts/pysource.py
index 71e0ded..98a78f0 100644
--- a/Tools/scripts/pysource.py
+++ b/Tools/scripts/pysource.py
@@ -33,7 +33,7 @@ def print_debug(msg):
def _open(fullpath):
try:
size = os.stat(fullpath).st_size
- except OSError, err: # Permission denied - ignore the file
+ except OSError as err: # Permission denied - ignore the file
print_debug("%s: permission denied: %s" % (fullpath, err))
return None
@@ -43,7 +43,7 @@ def _open(fullpath):
try:
return open(fullpath, 'rU')
- except IOError, err: # Access denied, or a special file - ignore it
+ except IOError as err: # Access denied, or a special file - ignore it
print_debug("%s: access denied: %s" % (fullpath, err))
return None
@@ -81,7 +81,7 @@ def can_be_compiled(fullpath):
try:
compile(code, fullpath, "exec")
- except Exception, err:
+ except Exception as err:
print_debug("%s: cannot compile: %s" % (fullpath, err))
return False
diff --git a/Tools/scripts/redemo.py b/Tools/scripts/redemo.py
index de7f3c4..b9bfb96 100644
--- a/Tools/scripts/redemo.py
+++ b/Tools/scripts/redemo.py
@@ -104,7 +104,7 @@ class ReDemo:
self.getflags())
bg = self.promptdisplay['background']
self.statusdisplay.config(text="", background=bg)
- except re.error, msg:
+ except re.error as msg:
self.compiled = None
self.statusdisplay.config(
text="re.error: %s" % str(msg),
diff --git a/Tools/scripts/reindent.py b/Tools/scripts/reindent.py
index 5ac98c7..70242cc 100644
--- a/Tools/scripts/reindent.py
+++ b/Tools/scripts/reindent.py
@@ -61,7 +61,7 @@ def main():
try:
opts, args = getopt.getopt(sys.argv[1:], "drvh",
["dryrun", "recurse", "verbose", "help"])
- except getopt.error, msg:
+ except getopt.error as msg:
usage(msg)
return
for o, a in opts:
@@ -99,7 +99,7 @@ def check(file):
print "checking", file, "...",
try:
f = open(file)
- except IOError, msg:
+ except IOError as msg:
errprint("%s: I/O Error: %s" % (file, str(msg)))
return
diff --git a/Tools/scripts/rgrep.py b/Tools/scripts/rgrep.py
index b644206..9d3d595 100755
--- a/Tools/scripts/rgrep.py
+++ b/Tools/scripts/rgrep.py
@@ -23,11 +23,11 @@ def main():
pattern, filename = args
try:
prog = re.compile(pattern, reflags)
- except re.error, msg:
+ except re.error as msg:
usage("error in regular expression: %s" % str(msg))
try:
f = open(filename)
- except IOError, msg:
+ except IOError as msg:
usage("can't open %s: %s" % (repr(filename), str(msg)), 1)
f.seek(0, 2)
pos = f.tell()
diff --git a/Tools/scripts/texi2html.py b/Tools/scripts/texi2html.py
index 3ecaee6..d849d7c 100755
--- a/Tools/scripts/texi2html.py
+++ b/Tools/scripts/texi2html.py
@@ -554,7 +554,7 @@ class TexinfoParser:
file = os.path.join(self.includedir, file)
try:
fp = open(file, 'r')
- except IOError, msg:
+ except IOError as msg:
print '*** Can\'t open include file', repr(file)
return
print '!'*self.debugging, '--> file', repr(file)
@@ -1797,7 +1797,7 @@ class HTMLHelp:
print>>fp, ''
self.dumpfiles(fp)
fp.close()
- except IOError, msg:
+ except IOError as msg:
print projectfile, ':', msg
sys.exit(1)
@@ -1822,7 +1822,7 @@ class HTMLHelp:
print>>fp, '</BODY>'
print>>fp, '</HTML>'
fp.close()
- except IOError, msg:
+ except IOError as msg:
print contentfile, ':', msg
sys.exit(1)
@@ -1844,7 +1844,7 @@ class HTMLHelp:
print>>fp, '</BODY>'
print>>fp, '</HTML>'
fp.close()
- except IOError, msg:
+ except IOError as msg:
print indexfile , ':', msg
sys.exit(1)
@@ -2063,7 +2063,7 @@ def test():
try:
fp = open(file, 'r')
- except IOError, msg:
+ except IOError as msg:
print file, ':', msg
sys.exit(1)
diff --git a/Tools/scripts/treesync.py b/Tools/scripts/treesync.py
index 4fb1798..a7a2098 100755
--- a/Tools/scripts/treesync.py
+++ b/Tools/scripts/treesync.py
@@ -78,7 +78,7 @@ def process(slave, master):
print "creating slave directory", slave
try:
os.mkdir(slave)
- except os.error, msg:
+ except os.error as msg:
print "can't make slave directory", slave, ":", msg
return
else:
diff --git a/Tools/scripts/untabify.py b/Tools/scripts/untabify.py
index 9bdf235..e4a2cc0 100755
--- a/Tools/scripts/untabify.py
+++ b/Tools/scripts/untabify.py
@@ -12,7 +12,7 @@ def main():
opts, args = getopt.getopt(sys.argv[1:], "t:")
if not args:
raise getopt.error, "At least one file argument required"
- except getopt.error, msg:
+ except getopt.error as msg:
print msg
print "usage:", sys.argv[0], "[-t tabwidth] file ..."
return
@@ -28,7 +28,7 @@ def process(filename, tabsize):
f = open(filename)
text = f.read()
f.close()
- except IOError, msg:
+ except IOError as msg:
print "%r: I/O error: %s" % (filename, msg)
return
newtext = text.expandtabs(tabsize)
diff --git a/Tools/unicode/comparecodecs.py b/Tools/unicode/comparecodecs.py
index cd417a4..a293283 100644
--- a/Tools/unicode/comparecodecs.py
+++ b/Tools/unicode/comparecodecs.py
@@ -18,11 +18,11 @@ def compare_codecs(encoding1, encoding2):
u = unichr(i)
try:
c1 = u.encode(encoding1)
- except UnicodeError, reason:
+ except UnicodeError as reason:
c1 = '<undefined>'
try:
c2 = u.encode(encoding2)
- except UnicodeError, reason:
+ except UnicodeError as reason:
c2 = '<undefined>'
if c1 != c2:
print ' * encoding mismatch for 0x%04X: %-14r != %r' % \
diff --git a/Tools/unicode/gencodec.py b/Tools/unicode/gencodec.py
index dabcd72..47d81eb 100644
--- a/Tools/unicode/gencodec.py
+++ b/Tools/unicode/gencodec.py
@@ -130,7 +130,7 @@ def hexrepr(t, precision=4):
try:
return '(' + ', '.join(['0x%0*X' % (precision, item)
for item in t]) + ')'
- except TypeError, why:
+ except TypeError as why:
print '* failed to convert %r: %s' % (t, why)
raise
@@ -393,7 +393,7 @@ def convertdir(dir, dirprefix='', nameprefix='', comments=1):
else:
pymap(mappathname, map, dirprefix + codefile,name,comments)
marshalmap(mappathname, map, dirprefix + marshalfile)
- except ValueError, why:
+ except ValueError as why:
print '* conversion failed: %s' % why
raise
@@ -414,7 +414,7 @@ def rewritepythondir(dir, dirprefix='', comments=1):
print '* map is empty; skipping'
else:
pymap(mapname, map, dirprefix + codefile,name,comments)
- except ValueError, why:
+ except ValueError as why:
print '* conversion failed: %s' % why
if __name__ == '__main__':
diff --git a/Tools/unicode/listcodecs.py b/Tools/unicode/listcodecs.py
index 19d21e1..c196ced 100644
--- a/Tools/unicode/listcodecs.py
+++ b/Tools/unicode/listcodecs.py
@@ -22,7 +22,7 @@ def listcodecs(dir):
except LookupError:
# Codec not found
continue
- except Exception, reason:
+ except Exception as reason:
# Probably an error from importing the codec; still it's
# a valid code name
if _debug:
diff --git a/Tools/versioncheck/pyversioncheck.py b/Tools/versioncheck/pyversioncheck.py
index 1446653..00ea496 100644
--- a/Tools/versioncheck/pyversioncheck.py
+++ b/Tools/versioncheck/pyversioncheck.py
@@ -49,7 +49,7 @@ def _check1version(package, url, version, verbose=0):
print ' Checking %s'%url
try:
fp = urllib.urlopen(url)
- except IOError, arg:
+ except IOError as arg:
if verbose >= VERBOSE_EACHFILE:
print ' Cannot open:', arg
return -1, None, None
diff --git a/Tools/webchecker/wcgui.py b/Tools/webchecker/wcgui.py
index 96aed0a..c6e216c 100755
--- a/Tools/webchecker/wcgui.py
+++ b/Tools/webchecker/wcgui.py
@@ -74,7 +74,7 @@ if sys.platform == 'mac':
def main():
try:
opts, args = getopt.getopt(sys.argv[1:], 't:m:qva')
- except getopt.error, msg:
+ except getopt.error as msg:
sys.stdout = sys.stderr
print msg
print __doc__%vars(webchecker)
diff --git a/Tools/webchecker/webchecker.py b/Tools/webchecker/webchecker.py
index 923e8e6..10e93c7 100755
--- a/Tools/webchecker/webchecker.py
+++ b/Tools/webchecker/webchecker.py
@@ -153,7 +153,7 @@ def main():
try:
opts, args = getopt.getopt(sys.argv[1:], 'Rd:m:nqr:t:vxa')
- except getopt.error, msg:
+ except getopt.error as msg:
sys.stdout = sys.stderr
print msg
print __doc__%globals()
@@ -335,7 +335,7 @@ class Checker:
rp.set_url(url)
try:
rp.read()
- except (OSError, IOError), msg:
+ except (OSError, IOError) as msg:
self.note(1, "I/O error parsing %s: %s", url, msg)
def run(self):
@@ -402,7 +402,7 @@ class Checker:
return
try:
page = self.getpage(url_pair)
- except sgmllib.SGMLParseError, msg:
+ except sgmllib.SGMLParseError as msg:
msg = self.sanitize(msg)
self.note(0, "Error parsing %s: %s",
self.format_url(url_pair), msg)
@@ -541,7 +541,7 @@ class Checker:
url, fragment = url_pair
try:
return self.urlopener.open(url)
- except (OSError, IOError), msg:
+ except (OSError, IOError) as msg:
msg = self.sanitize(msg)
self.note(0, "Error %s", msg)
if self.verbose > 0:
@@ -759,7 +759,7 @@ class MyURLopener(urllib.FancyURLopener):
return self.open_file(url + "index.html")
try:
names = os.listdir(path)
- except os.error, msg:
+ except os.error as msg:
exc_type, exc_value, exc_tb = sys.exc_info()
raise IOError, msg, exc_tb
names.sort()
diff --git a/Tools/webchecker/websucker.py b/Tools/webchecker/websucker.py
index ef2fa44..239cb52 100755
--- a/Tools/webchecker/websucker.py
+++ b/Tools/webchecker/websucker.py
@@ -21,7 +21,7 @@ def main():
verbose = webchecker.VERBOSE
try:
opts, args = getopt.getopt(sys.argv[1:], "qv")
- except getopt.error, msg:
+ except getopt.error as msg:
print msg
print "usage:", sys.argv[0], "[-qv] ... [rooturl] ..."
return 2
@@ -83,7 +83,7 @@ class Sucker(webchecker.Checker):
f.write(text)
f.close()
self.message("saved %s", path)
- except IOError, msg:
+ except IOError as msg:
self.message("didn't save %s: %s", path, str(msg))
def savefilename(self, url):