summaryrefslogtreecommitdiffstats
path: root/Lib/distutils
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/distutils')
-rw-r--r--Lib/distutils/bcppcompiler.py10
-rw-r--r--Lib/distutils/command/register.py4
-rw-r--r--Lib/distutils/command/sdist.py2
-rw-r--r--Lib/distutils/command/upload.py2
-rw-r--r--Lib/distutils/core.py8
-rw-r--r--Lib/distutils/cygwinccompiler.py6
-rw-r--r--Lib/distutils/dir_util.py7
-rw-r--r--Lib/distutils/dist.py6
-rw-r--r--Lib/distutils/emxccompiler.py6
-rw-r--r--Lib/distutils/fancy_getopt.py2
-rw-r--r--Lib/distutils/file_util.py23
-rw-r--r--Lib/distutils/msvccompiler.py12
-rw-r--r--Lib/distutils/spawn.py8
-rw-r--r--Lib/distutils/sysconfig.py4
-rw-r--r--Lib/distutils/unixccompiler.py8
-rw-r--r--Lib/distutils/util.py2
16 files changed, 59 insertions, 51 deletions
diff --git a/Lib/distutils/bcppcompiler.py b/Lib/distutils/bcppcompiler.py
index ca524a5..6968cb8 100644
--- a/Lib/distutils/bcppcompiler.py
+++ b/Lib/distutils/bcppcompiler.py
@@ -115,7 +115,7 @@ class BCPPCompiler(CCompiler) :
# This needs to be compiled to a .res file -- do it now.
try:
self.spawn (["brcc32", "-fo", obj, src])
- except DistutilsExecError, msg:
+ except DistutilsExecError as msg:
raise CompileError, msg
continue # the 'for' loop
@@ -139,7 +139,7 @@ class BCPPCompiler(CCompiler) :
self.spawn ([self.cc] + compile_opts + pp_opts +
[input_opt, output_opt] +
extra_postargs + [src])
- except DistutilsExecError, msg:
+ except DistutilsExecError as msg:
raise CompileError, msg
return objects
@@ -164,7 +164,7 @@ class BCPPCompiler(CCompiler) :
pass # XXX what goes here?
try:
self.spawn ([self.lib] + lib_args)
- except DistutilsExecError, msg:
+ except DistutilsExecError as msg:
raise LibError, msg
else:
log.debug("skipping %s (up-to-date)", output_filename)
@@ -298,7 +298,7 @@ class BCPPCompiler(CCompiler) :
self.mkpath (os.path.dirname (output_filename))
try:
self.spawn ([self.linker] + ld_args)
- except DistutilsExecError, msg:
+ except DistutilsExecError as msg:
raise LinkError, msg
else:
@@ -391,7 +391,7 @@ class BCPPCompiler(CCompiler) :
self.mkpath(os.path.dirname(output_file))
try:
self.spawn(pp_args)
- except DistutilsExecError, msg:
+ except DistutilsExecError as msg:
print msg
raise CompileError, msg
diff --git a/Lib/distutils/command/register.py b/Lib/distutils/command/register.py
index 3177476..cb9525a 100644
--- a/Lib/distutils/command/register.py
+++ b/Lib/distutils/command/register.py
@@ -284,11 +284,11 @@ Your selection [default 1]: ''',
data = ''
try:
result = opener.open(req)
- except urllib2.HTTPError, e:
+ except urllib2.HTTPError as e:
if self.show_response:
data = e.fp.read()
result = e.code, e.msg
- except urllib2.URLError, e:
+ except urllib2.URLError as e:
result = 500, str(e)
else:
if self.show_response:
diff --git a/Lib/distutils/command/sdist.py b/Lib/distutils/command/sdist.py
index 3dfe6f2..eb2db50 100644
--- a/Lib/distutils/command/sdist.py
+++ b/Lib/distutils/command/sdist.py
@@ -333,7 +333,7 @@ class sdist (Command):
try:
self.filelist.process_template_line(line)
- except DistutilsTemplateError, msg:
+ except DistutilsTemplateError as msg:
self.warn("%s, line %d: %s" % (template.filename,
template.current_line,
msg))
diff --git a/Lib/distutils/command/upload.py b/Lib/distutils/command/upload.py
index 67ba080..7f96a47 100644
--- a/Lib/distutils/command/upload.py
+++ b/Lib/distutils/command/upload.py
@@ -184,7 +184,7 @@ class upload(Command):
http.putheader('Authorization', auth)
http.endheaders()
http.send(body)
- except socket.error, e:
+ except socket.error as e:
self.announce(str(e), log.ERROR)
return
diff --git a/Lib/distutils/core.py b/Lib/distutils/core.py
index 85a28fe..4dc8eb0 100644
--- a/Lib/distutils/core.py
+++ b/Lib/distutils/core.py
@@ -110,7 +110,7 @@ def setup (**attrs):
# (ie. everything except distclass) to initialize it
try:
_setup_distribution = dist = klass(attrs)
- except DistutilsSetupError, msg:
+ except DistutilsSetupError as msg:
if 'name' not in attrs:
raise SystemExit, "error in %s setup command: %s" % \
(attrs['name'], msg)
@@ -135,7 +135,7 @@ def setup (**attrs):
# fault, so turn them into SystemExit to suppress tracebacks.
try:
ok = dist.parse_command_line()
- except DistutilsArgError, msg:
+ except DistutilsArgError as msg:
raise SystemExit, gen_usage(dist.script_name) + "\nerror: %s" % msg
if DEBUG:
@@ -151,7 +151,7 @@ def setup (**attrs):
dist.run_commands()
except KeyboardInterrupt:
raise SystemExit, "interrupted"
- except (IOError, os.error), exc:
+ except (IOError, os.error) as exc:
error = grok_environment_error(exc)
if DEBUG:
@@ -161,7 +161,7 @@ def setup (**attrs):
raise SystemExit, error
except (DistutilsError,
- CCompilerError), msg:
+ CCompilerError) as msg:
if DEBUG:
raise
else:
diff --git a/Lib/distutils/cygwinccompiler.py b/Lib/distutils/cygwinccompiler.py
index 4fd23e6..44b5850 100644
--- a/Lib/distutils/cygwinccompiler.py
+++ b/Lib/distutils/cygwinccompiler.py
@@ -142,13 +142,13 @@ class CygwinCCompiler (UnixCCompiler):
# gcc needs '.res' and '.rc' compiled to object files !!!
try:
self.spawn(["windres", "-i", src, "-o", obj])
- except DistutilsExecError, msg:
+ except DistutilsExecError as msg:
raise CompileError, msg
else: # for other files use the C-compiler
try:
self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
extra_postargs)
- except DistutilsExecError, msg:
+ except DistutilsExecError as msg:
raise CompileError, msg
def link (self,
@@ -379,7 +379,7 @@ def check_config_h():
s = f.read()
f.close()
- except IOError, exc:
+ except IOError as exc:
# if we can't read this file, we cannot say it is wrong
# the compiler will complain later about this file as missing
return (CONFIG_H_UNCERTAIN,
diff --git a/Lib/distutils/dir_util.py b/Lib/distutils/dir_util.py
index 92f4934..398f242 100644
--- a/Lib/distutils/dir_util.py
+++ b/Lib/distutils/dir_util.py
@@ -75,7 +75,7 @@ def mkpath (name, mode=0777, verbose=0, dry_run=0):
try:
os.mkdir(head)
created_dirs.append(head)
- except OSError, exc:
+ except OSError as exc:
raise DistutilsFileError, \
"could not create '%s': %s" % (head, exc[-1])
@@ -142,7 +142,8 @@ def copy_tree (src, dst,
"cannot copy tree '%s': not a directory" % src
try:
names = os.listdir(src)
- except os.error, (errno, errstr):
+ except os.error as e:
+ (errno, errstr) = e
if dry_run:
names = []
else:
@@ -209,7 +210,7 @@ def remove_tree (directory, verbose=0, dry_run=0):
abspath = os.path.abspath(cmd[1])
if abspath in _path_created:
del _path_created[abspath]
- except (IOError, OSError), exc:
+ except (IOError, OSError) as exc:
log.warn(grok_environment_error(
exc, "error removing %s: " % directory))
diff --git a/Lib/distutils/dist.py b/Lib/distutils/dist.py
index d098cb9..d21c5e2 100644
--- a/Lib/distutils/dist.py
+++ b/Lib/distutils/dist.py
@@ -398,7 +398,7 @@ Common commands: (see '--help-commands' for more)
setattr(self, opt, strtobool(val))
else:
setattr(self, opt, val)
- except ValueError, msg:
+ except ValueError as msg:
raise DistutilsOptionError, msg
# parse_config_files ()
@@ -515,7 +515,7 @@ Common commands: (see '--help-commands' for more)
# it takes.
try:
cmd_class = self.get_command_class(command)
- except DistutilsModuleError, msg:
+ except DistutilsModuleError as msg:
raise DistutilsArgError, msg
# Require that the command class be derived from Command -- want
@@ -917,7 +917,7 @@ Common commands: (see '--help-commands' for more)
raise DistutilsOptionError, \
("error in %s: command '%s' has no such option '%s'"
% (source, command_name, option))
- except ValueError, msg:
+ except ValueError as msg:
raise DistutilsOptionError, msg
def reinitialize_command (self, command, reinit_subcommands=0):
diff --git a/Lib/distutils/emxccompiler.py b/Lib/distutils/emxccompiler.py
index f52e632..8aef2b7 100644
--- a/Lib/distutils/emxccompiler.py
+++ b/Lib/distutils/emxccompiler.py
@@ -79,13 +79,13 @@ class EMXCCompiler (UnixCCompiler):
# gcc requires '.rc' compiled to binary ('.res') files !!!
try:
self.spawn(["rc", "-r", src])
- except DistutilsExecError, msg:
+ except DistutilsExecError as msg:
raise CompileError, msg
else: # for other files use the C-compiler
try:
self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
extra_postargs)
- except DistutilsExecError, msg:
+ except DistutilsExecError as msg:
raise CompileError, msg
def link (self,
@@ -275,7 +275,7 @@ def check_config_h():
s = f.read()
f.close()
- except IOError, exc:
+ except IOError as exc:
# if we can't read this file, we cannot say it is wrong
# the compiler will complain later about this file as missing
return (CONFIG_H_UNCERTAIN,
diff --git a/Lib/distutils/fancy_getopt.py b/Lib/distutils/fancy_getopt.py
index 31cf0c5..62a24e8 100644
--- a/Lib/distutils/fancy_getopt.py
+++ b/Lib/distutils/fancy_getopt.py
@@ -256,7 +256,7 @@ class FancyGetopt:
short_opts = string.join(self.short_opts)
try:
opts, args = getopt.getopt(args, short_opts, self.long_opts)
- except getopt.error, msg:
+ except getopt.error as msg:
raise DistutilsArgError, msg
for opt, val in opts:
diff --git a/Lib/distutils/file_util.py b/Lib/distutils/file_util.py
index 37b152e..c225ad3 100644
--- a/Lib/distutils/file_util.py
+++ b/Lib/distutils/file_util.py
@@ -32,27 +32,31 @@ def _copy_file_contents (src, dst, buffer_size=16*1024):
try:
try:
fsrc = open(src, 'rb')
- except os.error, (errno, errstr):
+ except os.error as e:
+ (errno, errstr) = e
raise DistutilsFileError, \
"could not open '%s': %s" % (src, errstr)
if os.path.exists(dst):
try:
os.unlink(dst)
- except os.error, (errno, errstr):
+ except os.error as e:
+ (errno, errstr) = e
raise DistutilsFileError, \
"could not delete '%s': %s" % (dst, errstr)
try:
fdst = open(dst, 'wb')
- except os.error, (errno, errstr):
+ except os.error as e:
+ (errno, errstr) = e
raise DistutilsFileError, \
"could not create '%s': %s" % (dst, errstr)
while 1:
try:
buf = fsrc.read(buffer_size)
- except os.error, (errno, errstr):
+ except os.error as e:
+ (errno, errstr) = e
raise DistutilsFileError, \
"could not read from '%s': %s" % (src, errstr)
@@ -61,7 +65,8 @@ def _copy_file_contents (src, dst, buffer_size=16*1024):
try:
fdst.write(buf)
- except os.error, (errno, errstr):
+ except os.error as e:
+ (errno, errstr) = e
raise DistutilsFileError, \
"could not write to '%s': %s" % (dst, errstr)
@@ -146,7 +151,7 @@ def copy_file (src, dst,
import macostools
try:
macostools.copy(src, dst, 0, preserve_times)
- except os.error, exc:
+ except os.error as exc:
raise DistutilsFileError, \
"could not copy '%s' to '%s': %s" % (src, dst, exc[-1])
@@ -217,7 +222,8 @@ def move_file (src, dst,
copy_it = 0
try:
os.rename(src, dst)
- except os.error, (num, msg):
+ except os.error as e:
+ (num, msg) = e
if num == errno.EXDEV:
copy_it = 1
else:
@@ -228,7 +234,8 @@ def move_file (src, dst,
copy_file(src, dst)
try:
os.unlink(src)
- except os.error, (num, msg):
+ except os.error as e:
+ (num, msg) = e
try:
os.unlink(dst)
except os.error:
diff --git a/Lib/distutils/msvccompiler.py b/Lib/distutils/msvccompiler.py
index 9ec3508..968a4ff 100644
--- a/Lib/distutils/msvccompiler.py
+++ b/Lib/distutils/msvccompiler.py
@@ -129,7 +129,7 @@ class MacroExpander:
self.set_macro("FrameworkSDKDir", net, "sdkinstallrootv1.1")
else:
self.set_macro("FrameworkSDKDir", net, "sdkinstallroot")
- except KeyError, exc: #
+ except KeyError as exc: #
raise DistutilsPlatformError, \
("""Python was built with Visual Studio 2003;
extensions must be built with a compiler than can generate compatible binaries.
@@ -371,7 +371,7 @@ class MSVCCompiler (CCompiler) :
try:
self.spawn ([self.rc] + pp_opts +
[output_opt] + [input_opt])
- except DistutilsExecError, msg:
+ except DistutilsExecError as msg:
raise CompileError, msg
continue
elif ext in self._mc_extensions:
@@ -400,7 +400,7 @@ class MSVCCompiler (CCompiler) :
self.spawn ([self.rc] +
["/fo" + obj] + [rc_file])
- except DistutilsExecError, msg:
+ except DistutilsExecError as msg:
raise CompileError, msg
continue
else:
@@ -414,7 +414,7 @@ class MSVCCompiler (CCompiler) :
self.spawn ([self.cc] + compile_opts + pp_opts +
[input_opt, output_opt] +
extra_postargs)
- except DistutilsExecError, msg:
+ except DistutilsExecError as msg:
raise CompileError, msg
return objects
@@ -440,7 +440,7 @@ class MSVCCompiler (CCompiler) :
pass # XXX what goes here?
try:
self.spawn ([self.lib] + lib_args)
- except DistutilsExecError, msg:
+ except DistutilsExecError as msg:
raise LibError, msg
else:
@@ -519,7 +519,7 @@ class MSVCCompiler (CCompiler) :
self.mkpath (os.path.dirname (output_filename))
try:
self.spawn ([self.linker] + ld_args)
- except DistutilsExecError, msg:
+ except DistutilsExecError as msg:
raise LinkError, msg
else:
diff --git a/Lib/distutils/spawn.py b/Lib/distutils/spawn.py
index e5654ff..6b07f52 100644
--- a/Lib/distutils/spawn.py
+++ b/Lib/distutils/spawn.py
@@ -78,7 +78,7 @@ def _spawn_nt (cmd,
# spawn for NT requires a full path to the .exe
try:
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
raise DistutilsExecError, \
"command '%s' failed: %s" % (cmd[0], exc[-1])
@@ -103,7 +103,7 @@ def _spawn_os2 (cmd,
# spawnv for OS/2 EMX requires a full path to the .exe
try:
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
raise DistutilsExecError, \
"command '%s' failed: %s" % (cmd[0], exc[-1])
@@ -131,7 +131,7 @@ def _spawn_posix (cmd,
#print "cmd[0] =", cmd[0]
#print "cmd =", cmd
exec_fn(cmd[0], cmd)
- except OSError, e:
+ except OSError as e:
sys.stderr.write("unable to execute %s: %s\n" %
(cmd[0], e.strerror))
os._exit(1)
@@ -146,7 +146,7 @@ def _spawn_posix (cmd,
while 1:
try:
(pid, status) = os.waitpid(pid, 0)
- except OSError, exc:
+ except OSError as exc:
import errno
if exc.errno == errno.EINTR:
continue
diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py
index 8989d92..9de7234 100644
--- a/Lib/distutils/sysconfig.py
+++ b/Lib/distutils/sysconfig.py
@@ -344,7 +344,7 @@ def _init_posix():
try:
filename = get_makefile_filename()
parse_makefile(filename, g)
- except IOError, msg:
+ except IOError as msg:
my_msg = "invalid Python installation: unable to open %s" % filename
if hasattr(msg, "strerror"):
my_msg = my_msg + " (%s)" % msg.strerror
@@ -355,7 +355,7 @@ def _init_posix():
try:
filename = get_config_h_filename()
parse_config_h(open(filename), g)
- except IOError, msg:
+ except IOError as msg:
my_msg = "invalid Python installation: unable to open %s" % filename
if hasattr(msg, "strerror"):
my_msg = my_msg + " (%s)" % msg.strerror
diff --git a/Lib/distutils/unixccompiler.py b/Lib/distutils/unixccompiler.py
index 75e8a53..0795f12 100644
--- a/Lib/distutils/unixccompiler.py
+++ b/Lib/distutils/unixccompiler.py
@@ -162,7 +162,7 @@ class UnixCCompiler(CCompiler):
self.mkpath(os.path.dirname(output_file))
try:
self.spawn(pp_args)
- except DistutilsExecError, msg:
+ except DistutilsExecError as msg:
raise CompileError, msg
def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
@@ -172,7 +172,7 @@ class UnixCCompiler(CCompiler):
try:
self.spawn(compiler_so + cc_args + [src, '-o', obj] +
extra_postargs)
- except DistutilsExecError, msg:
+ except DistutilsExecError as msg:
raise CompileError, msg
def create_static_lib(self, objects, output_libname,
@@ -196,7 +196,7 @@ class UnixCCompiler(CCompiler):
if self.ranlib:
try:
self.spawn(self.ranlib + [output_filename])
- except DistutilsExecError, msg:
+ except DistutilsExecError as msg:
raise LibError, msg
else:
log.debug("skipping %s (up-to-date)", output_filename)
@@ -250,7 +250,7 @@ class UnixCCompiler(CCompiler):
linker = _darwin_compiler_fixup(linker, ld_args)
self.spawn(linker + ld_args)
- except DistutilsExecError, msg:
+ except DistutilsExecError as msg:
raise LinkError, msg
else:
log.debug("skipping %s (up-to-date)", output_filename)
diff --git a/Lib/distutils/util.py b/Lib/distutils/util.py
index 1bcda93..16d8bcb 100644
--- a/Lib/distutils/util.py
+++ b/Lib/distutils/util.py
@@ -229,7 +229,7 @@ def subst_vars (s, local_vars):
try:
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
# subst_vars ()