summaryrefslogtreecommitdiff
path: root/Tools/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/scripts')
-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
30 files changed, 85 insertions, 85 deletions
diff --git a/Tools/scripts/byext.py b/Tools/scripts/byext.py
index 09610b00b9..998b4c0f72 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 ba38cafd17..b4d43356b9 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 a8714d9368..2025ba90bf 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 d30700fbf8..f65e63035e 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 3f2da3a986..0e90cd3d22 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 53b42943ce..eac59455b2 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 d938ae153e..c9f6ea8c28 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 97f63316c7..8fdc52b070 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 8dd4bfb3cb..f23316d573 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 537f0a1853..28a299aaa0 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 433a4254e4..29e0e1030c 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 b2cab888a6..98b8a817c9 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 1bf5c526b8..8e8ac59cd8 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 0ae4872003..eedf5ba12b 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 2ff15f41ef..c858e5911f 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 caade16551..39ef18e661 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 995f2efa9e..7f17046453 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 edfec2c45d..d07dfc6a13 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 e045f1a719..140c0b3e1a 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 b81871ff6a..11875a1835 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 88712b8140..2afc1326f8 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 7f6f191bbe..c59c0f21e3 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 89ed9e6999..9f444f2d2a 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 71e0ded9cf..98a78f0b46 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 de7f3c4a21..b9bfb9668b 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 5ac98c7f7b..70242cccd7 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 b64420645e..9d3d595c6b 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 3ecaee68fe..d849d7ccd9 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 4fb1798c60..a7a20987c9 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 9bdf235b67..e4a2cc0d59 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)