Commit ba04afa3 authored by Guido van Rossum's avatar Guido van Rossum

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
parent 6c3e3687
...@@ -115,7 +115,7 @@ class BCPPCompiler(CCompiler) : ...@@ -115,7 +115,7 @@ class BCPPCompiler(CCompiler) :
# This needs to be compiled to a .res file -- do it now. # This needs to be compiled to a .res file -- do it now.
try: try:
self.spawn (["brcc32", "-fo", obj, src]) self.spawn (["brcc32", "-fo", obj, src])
except DistutilsExecError, msg: except DistutilsExecError as msg:
raise CompileError, msg raise CompileError, msg
continue # the 'for' loop continue # the 'for' loop
...@@ -139,7 +139,7 @@ class BCPPCompiler(CCompiler) : ...@@ -139,7 +139,7 @@ class BCPPCompiler(CCompiler) :
self.spawn ([self.cc] + compile_opts + pp_opts + self.spawn ([self.cc] + compile_opts + pp_opts +
[input_opt, output_opt] + [input_opt, output_opt] +
extra_postargs + [src]) extra_postargs + [src])
except DistutilsExecError, msg: except DistutilsExecError as msg:
raise CompileError, msg raise CompileError, msg
return objects return objects
...@@ -164,7 +164,7 @@ class BCPPCompiler(CCompiler) : ...@@ -164,7 +164,7 @@ class BCPPCompiler(CCompiler) :
pass # XXX what goes here? pass # XXX what goes here?
try: try:
self.spawn ([self.lib] + lib_args) self.spawn ([self.lib] + lib_args)
except DistutilsExecError, msg: except DistutilsExecError as msg:
raise LibError, msg raise LibError, msg
else: else:
log.debug("skipping %s (up-to-date)", output_filename) log.debug("skipping %s (up-to-date)", output_filename)
...@@ -298,7 +298,7 @@ class BCPPCompiler(CCompiler) : ...@@ -298,7 +298,7 @@ class BCPPCompiler(CCompiler) :
self.mkpath (os.path.dirname (output_filename)) self.mkpath (os.path.dirname (output_filename))
try: try:
self.spawn ([self.linker] + ld_args) self.spawn ([self.linker] + ld_args)
except DistutilsExecError, msg: except DistutilsExecError as msg:
raise LinkError, msg raise LinkError, msg
else: else:
...@@ -391,7 +391,7 @@ class BCPPCompiler(CCompiler) : ...@@ -391,7 +391,7 @@ class BCPPCompiler(CCompiler) :
self.mkpath(os.path.dirname(output_file)) self.mkpath(os.path.dirname(output_file))
try: try:
self.spawn(pp_args) self.spawn(pp_args)
except DistutilsExecError, msg: except DistutilsExecError as msg:
print msg print msg
raise CompileError, msg raise CompileError, msg
......
...@@ -284,11 +284,11 @@ Your selection [default 1]: ''', ...@@ -284,11 +284,11 @@ Your selection [default 1]: ''',
data = '' data = ''
try: try:
result = opener.open(req) result = opener.open(req)
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
if self.show_response: if self.show_response:
data = e.fp.read() data = e.fp.read()
result = e.code, e.msg result = e.code, e.msg
except urllib2.URLError, e: except urllib2.URLError as e:
result = 500, str(e) result = 500, str(e)
else: else:
if self.show_response: if self.show_response:
......
...@@ -333,7 +333,7 @@ class sdist (Command): ...@@ -333,7 +333,7 @@ class sdist (Command):
try: try:
self.filelist.process_template_line(line) self.filelist.process_template_line(line)
except DistutilsTemplateError, msg: except DistutilsTemplateError as msg:
self.warn("%s, line %d: %s" % (template.filename, self.warn("%s, line %d: %s" % (template.filename,
template.current_line, template.current_line,
msg)) msg))
......
...@@ -184,7 +184,7 @@ class upload(Command): ...@@ -184,7 +184,7 @@ class upload(Command):
http.putheader('Authorization', auth) http.putheader('Authorization', auth)
http.endheaders() http.endheaders()
http.send(body) http.send(body)
except socket.error, e: except socket.error as e:
self.announce(str(e), log.ERROR) self.announce(str(e), log.ERROR)
return return
......
...@@ -110,7 +110,7 @@ def setup (**attrs): ...@@ -110,7 +110,7 @@ def setup (**attrs):
# (ie. everything except distclass) to initialize it # (ie. everything except distclass) to initialize it
try: try:
_setup_distribution = dist = klass(attrs) _setup_distribution = dist = klass(attrs)
except DistutilsSetupError, msg: except DistutilsSetupError as msg:
if 'name' not in attrs: if 'name' not in attrs:
raise SystemExit, "error in %s setup command: %s" % \ raise SystemExit, "error in %s setup command: %s" % \
(attrs['name'], msg) (attrs['name'], msg)
...@@ -135,7 +135,7 @@ def setup (**attrs): ...@@ -135,7 +135,7 @@ def setup (**attrs):
# fault, so turn them into SystemExit to suppress tracebacks. # fault, so turn them into SystemExit to suppress tracebacks.
try: try:
ok = dist.parse_command_line() ok = dist.parse_command_line()
except DistutilsArgError, msg: except DistutilsArgError as msg:
raise SystemExit, gen_usage(dist.script_name) + "\nerror: %s" % msg raise SystemExit, gen_usage(dist.script_name) + "\nerror: %s" % msg
if DEBUG: if DEBUG:
...@@ -151,7 +151,7 @@ def setup (**attrs): ...@@ -151,7 +151,7 @@ def setup (**attrs):
dist.run_commands() dist.run_commands()
except KeyboardInterrupt: except KeyboardInterrupt:
raise SystemExit, "interrupted" raise SystemExit, "interrupted"
except (IOError, os.error), exc: except (IOError, os.error) as exc:
error = grok_environment_error(exc) error = grok_environment_error(exc)
if DEBUG: if DEBUG:
...@@ -161,7 +161,7 @@ def setup (**attrs): ...@@ -161,7 +161,7 @@ def setup (**attrs):
raise SystemExit, error raise SystemExit, error
except (DistutilsError, except (DistutilsError,
CCompilerError), msg: CCompilerError) as msg:
if DEBUG: if DEBUG:
raise raise
else: else:
......
...@@ -142,13 +142,13 @@ class CygwinCCompiler (UnixCCompiler): ...@@ -142,13 +142,13 @@ class CygwinCCompiler (UnixCCompiler):
# gcc needs '.res' and '.rc' compiled to object files !!! # gcc needs '.res' and '.rc' compiled to object files !!!
try: try:
self.spawn(["windres", "-i", src, "-o", obj]) self.spawn(["windres", "-i", src, "-o", obj])
except DistutilsExecError, msg: except DistutilsExecError as msg:
raise CompileError, msg raise CompileError, msg
else: # for other files use the C-compiler else: # for other files use the C-compiler
try: try:
self.spawn(self.compiler_so + cc_args + [src, '-o', obj] + self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
extra_postargs) extra_postargs)
except DistutilsExecError, msg: except DistutilsExecError as msg:
raise CompileError, msg raise CompileError, msg
def link (self, def link (self,
...@@ -379,7 +379,7 @@ def check_config_h(): ...@@ -379,7 +379,7 @@ def check_config_h():
s = f.read() s = f.read()
f.close() f.close()
except IOError, exc: except IOError as exc:
# if we can't read this file, we cannot say it is wrong # if we can't read this file, we cannot say it is wrong
# the compiler will complain later about this file as missing # the compiler will complain later about this file as missing
return (CONFIG_H_UNCERTAIN, return (CONFIG_H_UNCERTAIN,
......
...@@ -75,7 +75,7 @@ def mkpath (name, mode=0777, verbose=0, dry_run=0): ...@@ -75,7 +75,7 @@ def mkpath (name, mode=0777, verbose=0, dry_run=0):
try: try:
os.mkdir(head) os.mkdir(head)
created_dirs.append(head) created_dirs.append(head)
except OSError, exc: except OSError as exc:
raise DistutilsFileError, \ raise DistutilsFileError, \
"could not create '%s': %s" % (head, exc[-1]) "could not create '%s': %s" % (head, exc[-1])
...@@ -142,7 +142,8 @@ def copy_tree (src, dst, ...@@ -142,7 +142,8 @@ def copy_tree (src, dst,
"cannot copy tree '%s': not a directory" % src "cannot copy tree '%s': not a directory" % src
try: try:
names = os.listdir(src) names = os.listdir(src)
except os.error, (errno, errstr): except os.error as e:
(errno, errstr) = e
if dry_run: if dry_run:
names = [] names = []
else: else:
...@@ -209,7 +210,7 @@ def remove_tree (directory, verbose=0, dry_run=0): ...@@ -209,7 +210,7 @@ def remove_tree (directory, verbose=0, dry_run=0):
abspath = os.path.abspath(cmd[1]) abspath = os.path.abspath(cmd[1])
if abspath in _path_created: if abspath in _path_created:
del _path_created[abspath] del _path_created[abspath]
except (IOError, OSError), exc: except (IOError, OSError) as exc:
log.warn(grok_environment_error( log.warn(grok_environment_error(
exc, "error removing %s: " % directory)) exc, "error removing %s: " % directory))
......
...@@ -398,7 +398,7 @@ Common commands: (see '--help-commands' for more) ...@@ -398,7 +398,7 @@ Common commands: (see '--help-commands' for more)
setattr(self, opt, strtobool(val)) setattr(self, opt, strtobool(val))
else: else:
setattr(self, opt, val) setattr(self, opt, val)
except ValueError, msg: except ValueError as msg:
raise DistutilsOptionError, msg raise DistutilsOptionError, msg
# parse_config_files () # parse_config_files ()
...@@ -515,7 +515,7 @@ Common commands: (see '--help-commands' for more) ...@@ -515,7 +515,7 @@ Common commands: (see '--help-commands' for more)
# it takes. # it takes.
try: try:
cmd_class = self.get_command_class(command) cmd_class = self.get_command_class(command)
except DistutilsModuleError, msg: except DistutilsModuleError as msg:
raise DistutilsArgError, msg raise DistutilsArgError, msg
# Require that the command class be derived from Command -- want # Require that the command class be derived from Command -- want
...@@ -917,7 +917,7 @@ Common commands: (see '--help-commands' for more) ...@@ -917,7 +917,7 @@ Common commands: (see '--help-commands' for more)
raise DistutilsOptionError, \ raise DistutilsOptionError, \
("error in %s: command '%s' has no such option '%s'" ("error in %s: command '%s' has no such option '%s'"
% (source, command_name, option)) % (source, command_name, option))
except ValueError, msg: except ValueError as msg:
raise DistutilsOptionError, msg raise DistutilsOptionError, msg
def reinitialize_command (self, command, reinit_subcommands=0): def reinitialize_command (self, command, reinit_subcommands=0):
......
...@@ -79,13 +79,13 @@ class EMXCCompiler (UnixCCompiler): ...@@ -79,13 +79,13 @@ class EMXCCompiler (UnixCCompiler):
# gcc requires '.rc' compiled to binary ('.res') files !!! # gcc requires '.rc' compiled to binary ('.res') files !!!
try: try:
self.spawn(["rc", "-r", src]) self.spawn(["rc", "-r", src])
except DistutilsExecError, msg: except DistutilsExecError as msg:
raise CompileError, msg raise CompileError, msg
else: # for other files use the C-compiler else: # for other files use the C-compiler
try: try:
self.spawn(self.compiler_so + cc_args + [src, '-o', obj] + self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
extra_postargs) extra_postargs)
except DistutilsExecError, msg: except DistutilsExecError as msg:
raise CompileError, msg raise CompileError, msg
def link (self, def link (self,
...@@ -275,7 +275,7 @@ def check_config_h(): ...@@ -275,7 +275,7 @@ def check_config_h():
s = f.read() s = f.read()
f.close() f.close()
except IOError, exc: except IOError as exc:
# if we can't read this file, we cannot say it is wrong # if we can't read this file, we cannot say it is wrong
# the compiler will complain later about this file as missing # the compiler will complain later about this file as missing
return (CONFIG_H_UNCERTAIN, return (CONFIG_H_UNCERTAIN,
......
...@@ -256,7 +256,7 @@ class FancyGetopt: ...@@ -256,7 +256,7 @@ class FancyGetopt:
short_opts = string.join(self.short_opts) short_opts = string.join(self.short_opts)
try: try:
opts, args = getopt.getopt(args, short_opts, self.long_opts) opts, args = getopt.getopt(args, short_opts, self.long_opts)
except getopt.error, msg: except getopt.error as msg:
raise DistutilsArgError, msg raise DistutilsArgError, msg
for opt, val in opts: for opt, val in opts:
......
...@@ -32,27 +32,31 @@ def _copy_file_contents (src, dst, buffer_size=16*1024): ...@@ -32,27 +32,31 @@ def _copy_file_contents (src, dst, buffer_size=16*1024):
try: try:
try: try:
fsrc = open(src, 'rb') fsrc = open(src, 'rb')
except os.error, (errno, errstr): except os.error as e:
(errno, errstr) = e
raise DistutilsFileError, \ raise DistutilsFileError, \
"could not open '%s': %s" % (src, errstr) "could not open '%s': %s" % (src, errstr)
if os.path.exists(dst): if os.path.exists(dst):
try: try:
os.unlink(dst) os.unlink(dst)
except os.error, (errno, errstr): except os.error as e:
(errno, errstr) = e
raise DistutilsFileError, \ raise DistutilsFileError, \
"could not delete '%s': %s" % (dst, errstr) "could not delete '%s': %s" % (dst, errstr)
try: try:
fdst = open(dst, 'wb') fdst = open(dst, 'wb')
except os.error, (errno, errstr): except os.error as e:
(errno, errstr) = e
raise DistutilsFileError, \ raise DistutilsFileError, \
"could not create '%s': %s" % (dst, errstr) "could not create '%s': %s" % (dst, errstr)
while 1: while 1:
try: try:
buf = fsrc.read(buffer_size) buf = fsrc.read(buffer_size)
except os.error, (errno, errstr): except os.error as e:
(errno, errstr) = e
raise DistutilsFileError, \ raise DistutilsFileError, \
"could not read from '%s': %s" % (src, errstr) "could not read from '%s': %s" % (src, errstr)
...@@ -61,7 +65,8 @@ def _copy_file_contents (src, dst, buffer_size=16*1024): ...@@ -61,7 +65,8 @@ def _copy_file_contents (src, dst, buffer_size=16*1024):
try: try:
fdst.write(buf) fdst.write(buf)
except os.error, (errno, errstr): except os.error as e:
(errno, errstr) = e
raise DistutilsFileError, \ raise DistutilsFileError, \
"could not write to '%s': %s" % (dst, errstr) "could not write to '%s': %s" % (dst, errstr)
...@@ -146,7 +151,7 @@ def copy_file (src, dst, ...@@ -146,7 +151,7 @@ def copy_file (src, dst,
import macostools import macostools
try: try:
macostools.copy(src, dst, 0, preserve_times) macostools.copy(src, dst, 0, preserve_times)
except os.error, exc: except os.error as exc:
raise DistutilsFileError, \ raise DistutilsFileError, \
"could not copy '%s' to '%s': %s" % (src, dst, exc[-1]) "could not copy '%s' to '%s': %s" % (src, dst, exc[-1])
...@@ -217,7 +222,8 @@ def move_file (src, dst, ...@@ -217,7 +222,8 @@ def move_file (src, dst,
copy_it = 0 copy_it = 0
try: try:
os.rename(src, dst) os.rename(src, dst)
except os.error, (num, msg): except os.error as e:
(num, msg) = e
if num == errno.EXDEV: if num == errno.EXDEV:
copy_it = 1 copy_it = 1
else: else:
...@@ -228,7 +234,8 @@ def move_file (src, dst, ...@@ -228,7 +234,8 @@ def move_file (src, dst,
copy_file(src, dst) copy_file(src, dst)
try: try:
os.unlink(src) os.unlink(src)
except os.error, (num, msg): except os.error as e:
(num, msg) = e
try: try:
os.unlink(dst) os.unlink(dst)
except os.error: except os.error:
......
...@@ -129,7 +129,7 @@ class MacroExpander: ...@@ -129,7 +129,7 @@ class MacroExpander:
self.set_macro("FrameworkSDKDir", net, "sdkinstallrootv1.1") self.set_macro("FrameworkSDKDir", net, "sdkinstallrootv1.1")
else: else:
self.set_macro("FrameworkSDKDir", net, "sdkinstallroot") self.set_macro("FrameworkSDKDir", net, "sdkinstallroot")
except KeyError, exc: # except KeyError as exc: #
raise DistutilsPlatformError, \ raise DistutilsPlatformError, \
("""Python was built with Visual Studio 2003; ("""Python was built with Visual Studio 2003;
extensions must be built with a compiler than can generate compatible binaries. extensions must be built with a compiler than can generate compatible binaries.
...@@ -371,7 +371,7 @@ class MSVCCompiler (CCompiler) : ...@@ -371,7 +371,7 @@ class MSVCCompiler (CCompiler) :
try: try:
self.spawn ([self.rc] + pp_opts + self.spawn ([self.rc] + pp_opts +
[output_opt] + [input_opt]) [output_opt] + [input_opt])
except DistutilsExecError, msg: except DistutilsExecError as msg:
raise CompileError, msg raise CompileError, msg
continue continue
elif ext in self._mc_extensions: elif ext in self._mc_extensions:
...@@ -400,7 +400,7 @@ class MSVCCompiler (CCompiler) : ...@@ -400,7 +400,7 @@ class MSVCCompiler (CCompiler) :
self.spawn ([self.rc] + self.spawn ([self.rc] +
["/fo" + obj] + [rc_file]) ["/fo" + obj] + [rc_file])
except DistutilsExecError, msg: except DistutilsExecError as msg:
raise CompileError, msg raise CompileError, msg
continue continue
else: else:
...@@ -414,7 +414,7 @@ class MSVCCompiler (CCompiler) : ...@@ -414,7 +414,7 @@ class MSVCCompiler (CCompiler) :
self.spawn ([self.cc] + compile_opts + pp_opts + self.spawn ([self.cc] + compile_opts + pp_opts +
[input_opt, output_opt] + [input_opt, output_opt] +
extra_postargs) extra_postargs)
except DistutilsExecError, msg: except DistutilsExecError as msg:
raise CompileError, msg raise CompileError, msg
return objects return objects
...@@ -440,7 +440,7 @@ class MSVCCompiler (CCompiler) : ...@@ -440,7 +440,7 @@ class MSVCCompiler (CCompiler) :
pass # XXX what goes here? pass # XXX what goes here?
try: try:
self.spawn ([self.lib] + lib_args) self.spawn ([self.lib] + lib_args)
except DistutilsExecError, msg: except DistutilsExecError as msg:
raise LibError, msg raise LibError, msg
else: else:
...@@ -519,7 +519,7 @@ class MSVCCompiler (CCompiler) : ...@@ -519,7 +519,7 @@ class MSVCCompiler (CCompiler) :
self.mkpath (os.path.dirname (output_filename)) self.mkpath (os.path.dirname (output_filename))
try: try:
self.spawn ([self.linker] + ld_args) self.spawn ([self.linker] + ld_args)
except DistutilsExecError, msg: except DistutilsExecError as msg:
raise LinkError, msg raise LinkError, msg
else: else:
......
...@@ -78,7 +78,7 @@ def _spawn_nt (cmd, ...@@ -78,7 +78,7 @@ def _spawn_nt (cmd,
# spawn for NT requires a full path to the .exe # spawn for NT requires a full path to the .exe
try: try:
rc = os.spawnv(os.P_WAIT, executable, cmd) rc = os.spawnv(os.P_WAIT, executable, cmd)
except OSError, exc: except OSError as exc:
# this seems to happen when the command isn't found # this seems to happen when the command isn't found
raise DistutilsExecError, \ raise DistutilsExecError, \
"command '%s' failed: %s" % (cmd[0], exc[-1]) "command '%s' failed: %s" % (cmd[0], exc[-1])
...@@ -103,7 +103,7 @@ def _spawn_os2 (cmd, ...@@ -103,7 +103,7 @@ def _spawn_os2 (cmd,
# spawnv for OS/2 EMX requires a full path to the .exe # spawnv for OS/2 EMX requires a full path to the .exe
try: try:
rc = os.spawnv(os.P_WAIT, executable, cmd) rc = os.spawnv(os.P_WAIT, executable, cmd)
except OSError, exc: except OSError as exc:
# this seems to happen when the command isn't found # this seems to happen when the command isn't found
raise DistutilsExecError, \ raise DistutilsExecError, \
"command '%s' failed: %s" % (cmd[0], exc[-1]) "command '%s' failed: %s" % (cmd[0], exc[-1])
...@@ -131,7 +131,7 @@ def _spawn_posix (cmd, ...@@ -131,7 +131,7 @@ def _spawn_posix (cmd,
#print "cmd[0] =", cmd[0] #print "cmd[0] =", cmd[0]
#print "cmd =", cmd #print "cmd =", cmd
exec_fn(cmd[0], cmd) exec_fn(cmd[0], cmd)
except OSError, e: except OSError as e:
sys.stderr.write("unable to execute %s: %s\n" % sys.stderr.write("unable to execute %s: %s\n" %
(cmd[0], e.strerror)) (cmd[0], e.strerror))
os._exit(1) os._exit(1)
...@@ -146,7 +146,7 @@ def _spawn_posix (cmd, ...@@ -146,7 +146,7 @@ def _spawn_posix (cmd,
while 1: while 1:
try: try:
(pid, status) = os.waitpid(pid, 0) (pid, status) = os.waitpid(pid, 0)
except OSError, exc: except OSError as exc:
import errno import errno
if exc.errno == errno.EINTR: if exc.errno == errno.EINTR:
continue continue
......
...@@ -344,7 +344,7 @@ def _init_posix(): ...@@ -344,7 +344,7 @@ def _init_posix():
try: try:
filename = get_makefile_filename() filename = get_makefile_filename()
parse_makefile(filename, g) parse_makefile(filename, g)
except IOError, msg: except IOError as msg:
my_msg = "invalid Python installation: unable to open %s" % filename my_msg = "invalid Python installation: unable to open %s" % filename
if hasattr(msg, "strerror"): if hasattr(msg, "strerror"):
my_msg = my_msg + " (%s)" % msg.strerror my_msg = my_msg + " (%s)" % msg.strerror
...@@ -355,7 +355,7 @@ def _init_posix(): ...@@ -355,7 +355,7 @@ def _init_posix():
try: try:
filename = get_config_h_filename() filename = get_config_h_filename()
parse_config_h(open(filename), g) parse_config_h(open(filename), g)
except IOError, msg: except IOError as msg:
my_msg = "invalid Python installation: unable to open %s" % filename my_msg = "invalid Python installation: unable to open %s" % filename
if hasattr(msg, "strerror"): if hasattr(msg, "strerror"):
my_msg = my_msg + " (%s)" % msg.strerror my_msg = my_msg + " (%s)" % msg.strerror
......
...@@ -162,7 +162,7 @@ class UnixCCompiler(CCompiler): ...@@ -162,7 +162,7 @@ class UnixCCompiler(CCompiler):
self.mkpath(os.path.dirname(output_file)) self.mkpath(os.path.dirname(output_file))
try: try:
self.spawn(pp_args) self.spawn(pp_args)
except DistutilsExecError, msg: except DistutilsExecError as msg:
raise CompileError, msg raise CompileError, msg
def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts): def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
...@@ -172,7 +172,7 @@ class UnixCCompiler(CCompiler): ...@@ -172,7 +172,7 @@ class UnixCCompiler(CCompiler):
try: try:
self.spawn(compiler_so + cc_args + [src, '-o', obj] + self.spawn(compiler_so + cc_args + [src, '-o', obj] +
extra_postargs) extra_postargs)
except DistutilsExecError, msg: except DistutilsExecError as msg:
raise CompileError, msg raise CompileError, msg
def create_static_lib(self, objects, output_libname, def create_static_lib(self, objects, output_libname,
...@@ -196,7 +196,7 @@ class UnixCCompiler(CCompiler): ...@@ -196,7 +196,7 @@ class UnixCCompiler(CCompiler):
if self.ranlib: if self.ranlib:
try: try:
self.spawn(self.ranlib + [output_filename]) self.spawn(self.ranlib + [output_filename])
except DistutilsExecError, msg: except DistutilsExecError as msg:
raise LibError, msg raise LibError, msg
else: else:
log.debug("skipping %s (up-to-date)", output_filename) log.debug("skipping %s (up-to-date)", output_filename)
...@@ -250,7 +250,7 @@ class UnixCCompiler(CCompiler): ...@@ -250,7 +250,7 @@ class UnixCCompiler(CCompiler):
linker = _darwin_compiler_fixup(linker, ld_args) linker = _darwin_compiler_fixup(linker, ld_args)
self.spawn(linker + ld_args) self.spawn(linker + ld_args)
except DistutilsExecError, msg: except DistutilsExecError as msg:
raise LinkError, msg raise LinkError, msg
else: else:
log.debug("skipping %s (up-to-date)", output_filename) log.debug("skipping %s (up-to-date)", output_filename)
......
...@@ -229,7 +229,7 @@ def subst_vars (s, local_vars): ...@@ -229,7 +229,7 @@ def subst_vars (s, local_vars):
try: try:
return re.sub(r'\$([a-zA-Z_][a-zA-Z_0-9]*)', _subst, s) return re.sub(r'\$([a-zA-Z_][a-zA-Z_0-9]*)', _subst, s)
except KeyError, var: except KeyError as var:
raise ValueError, "invalid variable '$%s'" % var raise ValueError, "invalid variable '$%s'" % var
# subst_vars () # subst_vars ()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment