[jhbuild] Make exception raising/handling Python3-compatible
- From: Javier Jardón Cabezas <jjardon src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [jhbuild] Make exception raising/handling Python3-compatible
- Date: Wed, 10 Feb 2016 02:09:37 +0000 (UTC)
commit 2a8de2dfe9952493520e5a1f53a05a4244f59e81
Author: Boris Egorov <egorov linux com>
Date: Sat Oct 24 16:40:51 2015 +0600
Make exception raising/handling Python3-compatible
Signed-off-by: Boris Egorov <egorov linux com>
jhbuild/commands/base.py | 14 +++++++-------
jhbuild/commands/bot.py | 2 +-
jhbuild/commands/goalreport.py | 4 ++--
jhbuild/commands/make.py | 2 +-
jhbuild/commands/sanitycheck.py | 2 +-
jhbuild/config.py | 2 +-
jhbuild/defaults.jhbuildrc | 2 +-
jhbuild/frontends/autobuild.py | 8 ++++----
jhbuild/frontends/buildscript.py | 4 ++--
jhbuild/frontends/gtkui.py | 2 +-
jhbuild/frontends/terminal.py | 6 +++---
jhbuild/frontends/tinderbox.py | 14 +++++++-------
jhbuild/main.py | 8 ++++----
jhbuild/modtypes/__init__.py | 8 ++++----
jhbuild/modtypes/autotools.py | 2 +-
jhbuild/modtypes/linux.py | 4 ++--
jhbuild/modtypes/testmodule.py | 4 ++--
jhbuild/moduleset.py | 10 +++++-----
jhbuild/utils/cmds.py | 2 +-
jhbuild/utils/fileutils.py | 4 ++--
jhbuild/utils/httpcache.py | 4 ++--
jhbuild/utils/systeminstall.py | 2 +-
jhbuild/utils/trayicon.py | 2 +-
jhbuild/versioncontrol/darcs.py | 2 +-
jhbuild/versioncontrol/fossil.py | 2 +-
jhbuild/versioncontrol/hg.py | 2 +-
jhbuild/versioncontrol/svn.py | 2 +-
jhbuild/versioncontrol/tarball.py | 6 +++---
scripts/hg-update.py | 2 +-
scripts/mk-tarball-moduleset.py | 2 +-
30 files changed, 65 insertions(+), 65 deletions(-)
---
diff --git a/jhbuild/commands/base.py b/jhbuild/commands/base.py
index f66ac14..447a3ab 100644
--- a/jhbuild/commands/base.py
+++ b/jhbuild/commands/base.py
@@ -100,7 +100,7 @@ class cmd_updateone(Command):
module_set = jhbuild.moduleset.load(config)
try:
module_list = [module_set.get_module(modname, ignore_case = True) for modname in args]
- except KeyError, e:
+ except KeyError as e:
raise FatalError(_("A module called '%s' could not be found.") % e)
if not module_list:
@@ -138,7 +138,7 @@ class cmd_cleanone(Command):
module_set = jhbuild.moduleset.load(config)
try:
module_list = [module_set.get_module(modname, ignore_case = True) for modname in args]
- except KeyError, e:
+ except KeyError as e:
raise FatalError(_("A module called '%s' could not be found.") % e)
if not module_list:
@@ -325,7 +325,7 @@ class cmd_buildone(BuildCommand):
modname = modname.rstrip(os.sep)
try:
module = module_set.get_module(modname, ignore_case=True)
- except KeyError, e:
+ except KeyError as e:
default_repo = jhbuild.moduleset.get_default_repo()
if not default_repo:
continue
@@ -369,7 +369,7 @@ class cmd_run(Command):
return self.run(config, options, args)
try:
return os.execlp(args[0], *args)
- except OSError, exc:
+ except OSError as exc:
raise FatalError(_("Unable to execute the command '%(command)s': %(err)s") % {
'command':args[0], 'err':str(exc)})
@@ -379,7 +379,7 @@ class cmd_run(Command):
module_set = jhbuild.moduleset.load(config)
try:
module = module_set.get_module(module_name, ignore_case = True)
- except KeyError, e:
+ except KeyError as e:
raise FatalError(_("A module called '%s' could not be found.") % e)
build = jhbuild.frontends.get_buildscript(config, [module], module_set=module_set)
@@ -389,7 +389,7 @@ class cmd_run(Command):
workingdir = module.get_srcdir(build)
try:
build.execute(args, cwd=workingdir)
- except CommandError, exc:
+ except CommandError as exc:
if args:
raise FatalError(_("Unable to execute the command '%s'") % args[0])
else:
@@ -399,7 +399,7 @@ class cmd_run(Command):
os.execlp(args[0], *args)
except IndexError:
raise FatalError(_('No command given'))
- except OSError, exc:
+ except OSError as exc:
raise FatalError(_("Unable to execute the command '%(command)s': %(err)s") % {
'command':args[0], 'err':str(exc)})
diff --git a/jhbuild/commands/bot.py b/jhbuild/commands/bot.py
index fce9497..0919241 100644
--- a/jhbuild/commands/bot.py
+++ b/jhbuild/commands/bot.py
@@ -514,7 +514,7 @@ class cmd_bot(Command):
if changeHorizon is not None and not isinstance(changeHorizon, int):
raise ValueError("changeHorizon needs to be an int")
- except KeyError, e:
+ except KeyError as e:
log.msg("config dictionary is missing a required parameter")
log.msg("leaving old configuration in place")
raise
diff --git a/jhbuild/commands/goalreport.py b/jhbuild/commands/goalreport.py
index f841dfd..ac3615c 100644
--- a/jhbuild/commands/goalreport.py
+++ b/jhbuild/commands/goalreport.py
@@ -676,7 +676,7 @@ class cmd_goalreport(Command):
filename += '?action=raw'
try:
filename = httpcache.load(filename, age=0)
- except Exception, e:
+ except Exception as e:
logging.warning('could not download %s: %s' % (filename, e))
return
for line in file(filename):
@@ -723,7 +723,7 @@ class cmd_goalreport(Command):
filename += '?action=raw'
try:
filename = httpcache.load(filename, age=0)
- except Exception, e:
+ except Exception as e:
logging.warning('could not download %s: %s' % (filename, e))
return
for line in file(filename):
diff --git a/jhbuild/commands/make.py b/jhbuild/commands/make.py
index aad0045..2c67242 100644
--- a/jhbuild/commands/make.py
+++ b/jhbuild/commands/make.py
@@ -84,7 +84,7 @@ class cmd_make(Command):
try:
module = module_set.get_module(modname, ignore_case=True)
- except KeyError, e:
+ except KeyError as e:
default_repo = jhbuild.moduleset.get_default_repo()
if not default_repo:
logging.error(_('No module matching current directory %r in the moduleset') % (modname, ))
diff --git a/jhbuild/commands/sanitycheck.py b/jhbuild/commands/sanitycheck.py
index 5700d00..d44757a 100644
--- a/jhbuild/commands/sanitycheck.py
+++ b/jhbuild/commands/sanitycheck.py
@@ -166,7 +166,7 @@ class cmd_sanitycheck(Command):
uprint(_("Please copy the lacking macros (%(macros)s) in one of the following paths:
%(path)s") % \
{'macros': ', '.join(not_in_path), 'path': ', '.join(path)})
- except CommandError, exc:
+ except CommandError as exc:
uprint(str(exc))
register_command(cmd_sanitycheck)
diff --git a/jhbuild/config.py b/jhbuild/config.py
index cf5d3d4..4ae5d23 100644
--- a/jhbuild/config.py
+++ b/jhbuild/config.py
@@ -195,7 +195,7 @@ class Config:
if filename:
try:
execfile(filename, config)
- except Exception, e:
+ except Exception as e:
if isinstance(e, FatalError):
# raise FatalErrors back, as it means an error in include()
# and it will print a traceback, and provide a meaningful
diff --git a/jhbuild/defaults.jhbuildrc b/jhbuild/defaults.jhbuildrc
index 3f54b68..199891a 100644
--- a/jhbuild/defaults.jhbuildrc
+++ b/jhbuild/defaults.jhbuildrc
@@ -68,7 +68,7 @@ builddir_pattern = '%s'
try:
import multiprocessing
jobs = multiprocessing.cpu_count() + 1
-except ImportError, _e:
+except ImportError as _e:
try:
jobs = os.sysconf('SC_NPROCESSORS_ONLN') + 1
except (OSError, AttributeError, ValueError):
diff --git a/jhbuild/frontends/autobuild.py b/jhbuild/frontends/autobuild.py
index 6ba1397..28af241 100644
--- a/jhbuild/frontends/autobuild.py
+++ b/jhbuild/frontends/autobuild.py
@@ -62,10 +62,10 @@ class ServerProxy(xmlrpclib.ServerProxy):
for i in range(ITERS):
try:
return xmlrpclib.ServerProxy.__request(self, methodname, params)
- except xmlrpclib.ProtocolError, e:
+ except xmlrpclib.ProtocolError as e:
if e.errcode != 500:
raise
- except socket.error, e:
+ except socket.error as e:
pass
if i < ITERS-1:
if self.verbose_timeout:
@@ -176,7 +176,7 @@ class AutobuildBuildScript(buildscript.BuildScript, TerminalBuildScript):
try:
p = subprocess.Popen(command, **kws)
- except OSError, e:
+ except OSError as e:
self.phasefp.write('<span class="error">' + _('Error: %s') % escape(str(e)) + '</span>\n')
raise CommandError(str(e))
@@ -207,7 +207,7 @@ class AutobuildBuildScript(buildscript.BuildScript, TerminalBuildScript):
try:
self.build_id = self.server.start_build(info)
- except xmlrpclib.ProtocolError, e:
+ except xmlrpclib.ProtocolError as e:
if e.errcode == 403:
print >> sys.stderr, _('ERROR: Wrong credentials, please check username/password')
sys.exit(1)
diff --git a/jhbuild/frontends/buildscript.py b/jhbuild/frontends/buildscript.py
index afc4603..59eaf25 100644
--- a/jhbuild/frontends/buildscript.py
+++ b/jhbuild/frontends/buildscript.py
@@ -161,7 +161,7 @@ class BuildScript:
try:
try:
error, altphases = module.run_phase(self, phase)
- except SkipToPhase, e:
+ except SkipToPhase as e:
try:
num_phase = build_phases.index(e.phase)
except ValueError:
@@ -261,7 +261,7 @@ class BuildScript:
logging.info(_('Running post-installation trigger script: %r') % (trig.name, ))
try:
self.execute(trig.command())
- except CommandError, err:
+ except CommandError as err:
if isinstance(trig.command(), (str, unicode)):
displayed_command = trig.command()
else:
diff --git a/jhbuild/frontends/gtkui.py b/jhbuild/frontends/gtkui.py
index 62e2878..347d7e7 100644
--- a/jhbuild/frontends/gtkui.py
+++ b/jhbuild/frontends/gtkui.py
@@ -482,7 +482,7 @@ class AppWindow(gtk.Window, buildscript.BuildScript):
try:
p = subprocess.Popen(command, **kws)
- except OSError, e:
+ except OSError as e:
raise CommandError(str(e))
self.child_pid = p.pid
diff --git a/jhbuild/frontends/terminal.py b/jhbuild/frontends/terminal.py
index e4d3a9d..2bb70d6 100644
--- a/jhbuild/frontends/terminal.py
+++ b/jhbuild/frontends/terminal.py
@@ -175,9 +175,9 @@ class TerminalBuildScript(buildscript.BuildScript):
if self.config.print_command_pattern:
try:
print self.config.print_command_pattern % print_args
- except TypeError, e:
+ except TypeError as e:
raise FatalError('\'print_command_pattern\' %s' % e)
- except KeyError, e:
+ except KeyError as e:
raise FatalError(_('%(configuration_variable)s invalid key'
' %(key)s' % \
{'configuration_variable' :
@@ -207,7 +207,7 @@ class TerminalBuildScript(buildscript.BuildScript):
try:
p = subprocess.Popen(command, **kws)
- except OSError, e:
+ except OSError as e:
raise CommandError(str(e))
output = []
diff --git a/jhbuild/frontends/tinderbox.py b/jhbuild/frontends/tinderbox.py
index 6e5ae6f..f268290 100644
--- a/jhbuild/frontends/tinderbox.py
+++ b/jhbuild/frontends/tinderbox.py
@@ -213,9 +213,9 @@ class TinderboxBuildScript(buildscript.BuildScript):
commandstr = self.config.print_command_pattern % print_args
self.modulefp.write('<span class="command">%s</span>\n'
% escape(commandstr))
- except TypeError, e:
+ except TypeError as e:
raise FatalError('\'print_command_pattern\' %s' % e)
- except KeyError, e:
+ except KeyError as e:
raise FatalError(_('%(configuration_variable)s invalid key'
' %(key)s' % \
{'configuration_variable' :
@@ -254,7 +254,7 @@ class TinderboxBuildScript(buildscript.BuildScript):
try:
p = subprocess.Popen(command, **kws)
- except OSError, e:
+ except OSError as e:
self.modulefp.write('<span class="error">Error: %s</span>\n'
% escape(str(e)))
raise CommandError(str(e))
@@ -342,9 +342,9 @@ class TinderboxBuildScript(buildscript.BuildScript):
try:
help_url = self.config.help_website[1] % {'module' : module}
help_html = ' <a href="%s">(help)</a>' % help_url
- except TypeError, e:
+ except TypeError as e:
raise FatalError('"help_website" %s' % e)
- except KeyError, e:
+ except KeyError as e:
raise FatalError(_('%(configuration_variable)s invalid key'
' %(key)s' % \
{'configuration_variable' :
@@ -397,9 +397,9 @@ class TinderboxBuildScript(buildscript.BuildScript):
' for more information.</div>'
% {'name' : self.config.help_website[0],
'url' : help_url})
- except TypeError, e:
+ except TypeError as e:
raise FatalError('"help_website" %s' % e)
- except KeyError, e:
+ except KeyError as e:
raise FatalError(_('%(configuration_variable)s invalid key'
' %(key)s' % \
{'configuration_variable' :
diff --git a/jhbuild/main.py b/jhbuild/main.py
index da222f5..a5cf99b 100644
--- a/jhbuild/main.py
+++ b/jhbuild/main.py
@@ -135,7 +135,7 @@ def main(args):
try:
config = jhbuild.config.Config(options.configfile, options.conditions)
- except FatalError, exc:
+ except FatalError as exc:
sys.stderr.write('jhbuild: %s\n' % exc.args[0].encode(_encoding, 'replace'))
sys.exit(1)
@@ -153,11 +153,11 @@ def main(args):
try:
rc = jhbuild.commands.run(command, config, args, help=lambda: print_help(parser))
- except UsageError, exc:
+ except UsageError as exc:
sys.stderr.write('jhbuild %s: %s\n' % (command, exc.args[0].encode(_encoding, 'replace')))
parser.print_usage()
sys.exit(1)
- except FatalError, exc:
+ except FatalError as exc:
sys.stderr.write('jhbuild %s: %s\n' % (command, exc.args[0].encode(_encoding, 'replace')))
sys.exit(1)
except KeyboardInterrupt:
@@ -166,7 +166,7 @@ def main(args):
except EOFError:
uprint(_('EOF'))
sys.exit(1)
- except IOError, e:
+ except IOError as e:
if e.errno != errno.EPIPE:
raise
sys.exit(0)
diff --git a/jhbuild/modtypes/__init__.py b/jhbuild/modtypes/__init__.py
index 41daa3d..006ac30 100644
--- a/jhbuild/modtypes/__init__.py
+++ b/jhbuild/modtypes/__init__.py
@@ -294,9 +294,9 @@ them into the prefix."""
try:
fileutils.rename(src_path, dest_path)
num_copied += 1
- except OSError, e:
+ except OSError as e:
errors.append("%s: '%s'" % (str(e), dest_path))
- except OSError, e:
+ except OSError as e:
errors.append(str(e))
return num_copied
@@ -334,7 +334,7 @@ them into the prefix."""
assert target.startswith(buildscript.config.prefix)
try:
os.rmdir(target)
- except OSError, e:
+ except OSError as e:
pass
remaining_files = os.listdir(destdir)
@@ -418,7 +418,7 @@ them into the prefix."""
method = getattr(self, 'do_' + phase)
try:
method(buildscript)
- except (CommandError, BuildStateError), e:
+ except (CommandError, BuildStateError) as e:
error_phases = []
if hasattr(method, 'error_phases'):
error_phases = method.error_phases
diff --git a/jhbuild/modtypes/autotools.py b/jhbuild/modtypes/autotools.py
index 78a2ff3..b5eb90e 100644
--- a/jhbuild/modtypes/autotools.py
+++ b/jhbuild/modtypes/autotools.py
@@ -91,7 +91,7 @@ class AutogenModule(MakeModule, DownloadableModule):
try:
other_stbuf = os.stat(other)
potential_stbuf = os.stat(potential)
- except OSError, e:
+ except OSError as e:
return False
return potential_stbuf.st_mtime > other_stbuf.st_mtime
diff --git a/jhbuild/modtypes/linux.py b/jhbuild/modtypes/linux.py
index 3b1c17c..6b7be6f 100644
--- a/jhbuild/modtypes/linux.py
+++ b/jhbuild/modtypes/linux.py
@@ -114,8 +114,8 @@ class LinuxModule(MakeModule):
try:
os.makedirs(os.path.join(self.branch.srcdir, 'build-' + kconfig.version))
- except OSError, (e, msg):
- if e != errno.EEXIST:
+ except OSError as e:
+ if e.errno != errno.EEXIST:
raise
if kconfig.branch:
diff --git a/jhbuild/modtypes/testmodule.py b/jhbuild/modtypes/testmodule.py
index 1281766..da8f482 100644
--- a/jhbuild/modtypes/testmodule.py
+++ b/jhbuild/modtypes/testmodule.py
@@ -277,7 +277,7 @@ class TestModule(Package, DownloadableModule):
else:
buildscript.execute('ldtprunner run.xml', cwd=src_dir,
extra_env={'DISPLAY': ':%s' % self.screennum})
- except CommandError, e:
+ except CommandError as e:
os.kill(ldtp_pid, signal.SIGINT)
if e.returncode == 32512: # ldtprunner not installed
raise BuildStateError('ldtprunner not available')
@@ -317,7 +317,7 @@ class TestModule(Package, DownloadableModule):
try:
buildscript.execute('python %s' % test_case,
cwd=src_dir, extra_env=extra_env)
- except CommandError, e:
+ except CommandError as e:
if e.returncode != 0:
raise BuildStateError('%s failed' % test_case)
diff --git a/jhbuild/moduleset.py b/jhbuild/moduleset.py
index d16c068..c310377 100644
--- a/jhbuild/moduleset.py
+++ b/jhbuild/moduleset.py
@@ -176,7 +176,7 @@ class ModuleSet:
# remove skip modules from module_name list
modules = [self.get_module(module, ignore_case = True) \
for module in module_names if module not in skip]
- except KeyError, e:
+ except KeyError as e:
raise UsageError(_("A module called '%s' could not be found.") % e)
resolved = []
@@ -438,14 +438,14 @@ def _handle_conditions(config, element):
def _parse_module_set(config, uri):
try:
filename = httpcache.load(uri, nonetwork=config.nonetwork, age=0)
- except Exception, e:
+ except Exception as e:
raise FatalError(_('could not download %s: %s') % (uri, e))
filename = os.path.normpath(filename)
try:
document = xml.dom.minidom.parse(filename)
- except IOError, e:
+ except IOError as e:
raise FatalError(_('failed to parse %s: %s') % (filename, e))
- except xml.parsers.expat.ExpatError, e:
+ except xml.parsers.expat.ExpatError as e:
raise FatalError(_('failed to parse %s: %s') % (uri, e))
assert document.documentElement.nodeName == 'moduleset'
@@ -523,7 +523,7 @@ def _parse_module_set(config, uri):
inc_moduleset = _parse_module_set(config, inc_uri)
except UndefinedRepositoryError:
raise
- except FatalError, e:
+ except FatalError as e:
if inc_uri[0] == '/':
raise e
# look up in local modulesets
diff --git a/jhbuild/utils/cmds.py b/jhbuild/utils/cmds.py
index d0bbcac..d9d9d7c 100644
--- a/jhbuild/utils/cmds.py
+++ b/jhbuild/utils/cmds.py
@@ -59,7 +59,7 @@ def get_output(cmd, cwd=None, extra_env=None, get_stderr = True):
stdout=subprocess.PIPE,
stderr=stderr_output,
**kws)
- except OSError, e:
+ except OSError as e:
raise CommandError(str(e))
stdout, stderr = p.communicate()
if p.returncode != 0:
diff --git a/jhbuild/utils/fileutils.py b/jhbuild/utils/fileutils.py
index e06fb4a..46d1716 100644
--- a/jhbuild/utils/fileutils.py
+++ b/jhbuild/utils/fileutils.py
@@ -69,7 +69,7 @@ Returns a list, where each item is a 2-tuple:
else:
os.unlink(path)
results.append((path, True, ''))
- except OSError, e:
+ except OSError as e:
if (isdir
and allow_nonempty_dirs
and len(os.listdir(path)) > 0):
@@ -98,7 +98,7 @@ def _windows_rename(src, dst):
'''atomically rename file src to dst, replacing dst if it exists'''
try:
os.rename(src, dst)
- except OSError, e:
+ except OSError as e:
if e.errno != errno.EEXIST:
raise
# Windows does not allow to unlink open file.
diff --git a/jhbuild/utils/httpcache.py b/jhbuild/utils/httpcache.py
index c541d97..b5c6b29 100644
--- a/jhbuild/utils/httpcache.py
+++ b/jhbuild/utils/httpcache.py
@@ -43,7 +43,7 @@ except ImportError:
try:
import xml.dom.minidom
except ImportError:
- raise SystemExit, _('Python XML packages are required but could not be found')
+ raise SystemExit(_('Python XML packages are required but could not be found'))
def _parse_isotime(string):
if string[-1] != 'Z':
@@ -214,7 +214,7 @@ class Cache:
fp = open(filename, 'wb')
fp.write(data)
fp.close()
- except urllib2.HTTPError, e:
+ except urllib2.HTTPError as e:
if e.code == 304: # not modified; update validated
expires = e.hdrs.get('Expires')
filename = os.path.join(self.cachedir, entry.local)
diff --git a/jhbuild/utils/systeminstall.py b/jhbuild/utils/systeminstall.py
index ffd20d8..d941a16 100644
--- a/jhbuild/utils/systeminstall.py
+++ b/jhbuild/utils/systeminstall.py
@@ -197,7 +197,7 @@ class SystemInstall(object):
elif cmds.has_command('sudo'):
self._root_command_prefix_args = ['sudo']
else:
- raise SystemExit, _('No suitable root privilege command found; you should install "pkexec"')
+ raise SystemExit(_('No suitable root privilege command found; you should install "pkexec"'))
def install(self, uninstalled):
"""Takes a list of pkg-config identifiers and uses a system-specific method to install them."""
diff --git a/jhbuild/utils/trayicon.py b/jhbuild/utils/trayicon.py
index 6c74cab..16c6fba 100644
--- a/jhbuild/utils/trayicon.py
+++ b/jhbuild/utils/trayicon.py
@@ -95,7 +95,7 @@ class TrayIcon:
try:
self.proc.stdin.write(cmd)
self.proc.stdin.flush()
- except (IOError, OSError), err:
+ except (IOError, OSError) as err:
self.close()
def set_icon(self, icon):
self._send_cmd('icon: %s\n' % icon)
diff --git a/jhbuild/versioncontrol/darcs.py b/jhbuild/versioncontrol/darcs.py
index 1e08456..48758a9 100644
--- a/jhbuild/versioncontrol/darcs.py
+++ b/jhbuild/versioncontrol/darcs.py
@@ -101,7 +101,7 @@ class DarcsBranch(Branch):
path = os.path.join(self.srcdir, filename)
try:
stat = os.stat(path)
- except OSError, e:
+ except OSError as e:
continue
os.chmod(path, stat.st_mode | 0111)
diff --git a/jhbuild/versioncontrol/fossil.py b/jhbuild/versioncontrol/fossil.py
index 172072c..cda8943 100644
--- a/jhbuild/versioncontrol/fossil.py
+++ b/jhbuild/versioncontrol/fossil.py
@@ -112,7 +112,7 @@ class FossilBranch(Branch):
try:
infos = Popen(['fossil', 'info'], stdout=PIPE, cwd=self.srcdir)
- except OSError, e:
+ except OSError as e:
raise CommandError(str(e))
infos = infos.stdout.read().strip()
return re.search(r"checkout: +(\w+)", infos).group(1)
diff --git a/jhbuild/versioncontrol/hg.py b/jhbuild/versioncontrol/hg.py
index 6cc661a..b84e7ad 100644
--- a/jhbuild/versioncontrol/hg.py
+++ b/jhbuild/versioncontrol/hg.py
@@ -111,7 +111,7 @@ class HgBranch(Branch):
try:
hg = Popen(['hg', 'ti', '--template', '{node}'], stdout=PIPE,
cwd=self.srcdir)
- except OSError, e:
+ except OSError as e:
raise CommandError(str(e))
return hg.stdout.read().strip()
diff --git a/jhbuild/versioncontrol/svn.py b/jhbuild/versioncontrol/svn.py
index 0a67316..890a67f 100644
--- a/jhbuild/versioncontrol/svn.py
+++ b/jhbuild/versioncontrol/svn.py
@@ -306,7 +306,7 @@ class SubversionBranch(Branch):
try:
output = subprocess.Popen(['svn', 'info', '-R'],
stdout = subprocess.PIPE, **kws).communicate()[0]
- except OSError, e:
+ except OSError as e:
raise CommandError(str(e))
if '\nConflict' in output:
raise CommandError(_('Error checking for conflicts'))
diff --git a/jhbuild/versioncontrol/tarball.py b/jhbuild/versioncontrol/tarball.py
index 3ea4080..58c1a7e 100644
--- a/jhbuild/versioncontrol/tarball.py
+++ b/jhbuild/versioncontrol/tarball.py
@@ -254,9 +254,9 @@ class TarballBranch(Branch):
# patch name has scheme, get patch from network
try:
patchfile = httpcache.load(patch, nonetwork=buildscript.config.nonetwork)
- except urllib2.HTTPError, e:
+ except urllib2.HTTPError as e:
raise BuildStateError(_('could not download patch (error: %s)') % e.code)
- except urllib2.URLError, e:
+ except urllib2.URLError as e:
raise BuildStateError(_('could not download patch'))
elif self.repository.moduleset_uri:
# get it relative to the moduleset uri, either in the same
@@ -266,7 +266,7 @@ class TarballBranch(Branch):
os.path.join(patch_prefix, patch))
try:
patchfile = httpcache.load(uri, nonetwork=buildscript.config.nonetwork)
- except Exception, e:
+ except Exception as e:
continue
if not os.path.isfile(patchfile):
continue
diff --git a/scripts/hg-update.py b/scripts/hg-update.py
index cfe5b70..2ba03e9 100755
--- a/scripts/hg-update.py
+++ b/scripts/hg-update.py
@@ -74,7 +74,7 @@ if __name__ == '__main__':
ret = False
try:
ret = pull_and_update()
- except OSError, e:
+ except OSError as e:
print '%s: %s' % (sys.argv[0], e)
if ret:
diff --git a/scripts/mk-tarball-moduleset.py b/scripts/mk-tarball-moduleset.py
index 47553b3..f50f353 100755
--- a/scripts/mk-tarball-moduleset.py
+++ b/scripts/mk-tarball-moduleset.py
@@ -104,7 +104,7 @@ def main(args):
opts, args = getopt.getopt(args, 'd:u:s:x:h',
['dependencies=', 'uri=', 'source=',
'exceptions=', 'help'])
- except getopt.error, exc:
+ except getopt.error as exc:
sys.stderr.write('mk-tarball-moduleset: %s\n' % str(exc))
sys.stderr.write(usage + '\n')
sys.exit(1)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]