mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
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
This commit is contained in:
parent
893523e80a
commit
b940e113bf
295 changed files with 817 additions and 743 deletions
12
Lib/trace.py
12
Lib/trace.py
|
@ -220,7 +220,7 @@ class CoverageResults:
|
|||
counts, calledfuncs, callers = \
|
||||
pickle.load(open(self.infile, 'rb'))
|
||||
self.update(self.__class__(counts, calledfuncs, callers))
|
||||
except (IOError, EOFError, ValueError), err:
|
||||
except (IOError, EOFError, ValueError) as err:
|
||||
print >> sys.stderr, ("Skipping counts file %r: %s"
|
||||
% (self.infile, err))
|
||||
|
||||
|
@ -328,7 +328,7 @@ class CoverageResults:
|
|||
try:
|
||||
pickle.dump((self.counts, self.calledfuncs, self.callers),
|
||||
open(self.outfile, 'wb'), 1)
|
||||
except IOError, err:
|
||||
except IOError as err:
|
||||
print >> sys.stderr, "Can't save counts files because %s" % err
|
||||
|
||||
def write_results_file(self, path, lines, lnotab, lines_hit):
|
||||
|
@ -336,7 +336,7 @@ class CoverageResults:
|
|||
|
||||
try:
|
||||
outfile = open(path, "w")
|
||||
except IOError, err:
|
||||
except IOError as err:
|
||||
print >> sys.stderr, ("trace: Could not open %r for writing: %s"
|
||||
"- skipping" % (path, err))
|
||||
return 0, 0
|
||||
|
@ -422,7 +422,7 @@ def find_executable_linenos(filename):
|
|||
"""Return dict where keys are line numbers in the line number table."""
|
||||
try:
|
||||
prog = open(filename, "rU").read()
|
||||
except IOError, err:
|
||||
except IOError as err:
|
||||
print >> sys.stderr, ("Not printing coverage data for %r: %s"
|
||||
% (filename, err))
|
||||
return {}
|
||||
|
@ -658,7 +658,7 @@ def main(argv=None):
|
|||
"coverdir=", "listfuncs",
|
||||
"trackcalls"])
|
||||
|
||||
except getopt.error, msg:
|
||||
except getopt.error as msg:
|
||||
sys.stderr.write("%s: %s\n" % (sys.argv[0], msg))
|
||||
sys.stderr.write("Try `%s --help' for more information\n"
|
||||
% sys.argv[0])
|
||||
|
@ -778,7 +778,7 @@ def main(argv=None):
|
|||
outfile=counts_file)
|
||||
try:
|
||||
t.run('execfile(%r)' % (progname,))
|
||||
except IOError, err:
|
||||
except IOError as err:
|
||||
_err_exit("Cannot run file %r because: %s" % (sys.argv[0], err))
|
||||
except SystemExit:
|
||||
pass
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue