Switch to new try..except syntax

This is forward compatible to Python 3.
This commit is contained in:
René Stadler 2011-11-16 19:45:16 +01:00 committed by Stefan Sauer
parent ca9a31ddd9
commit 7a05a716d2
4 changed files with 11 additions and 11 deletions

View file

@ -363,7 +363,7 @@ class OptionParser (object):
try:
result_argv = context.parse (argv)
except gobject.GError, exc:
except gobject.GError as exc:
raise OptionError (exc.message)
self.__remaining_args = result_argv[1:]
@ -437,7 +437,7 @@ def _init_locale (gettext_domain = None):
if Paths.locale_dir and gettext_domain is not None:
try:
locale.setlocale (locale.LC_ALL, "")
except locale.Error, exc:
except locale.Error as exc:
from warnings import warn
warn ("locale error: %s" % (exc,),
RuntimeWarning,
@ -455,7 +455,7 @@ def _init_options (option_parser = None):
try:
option_parser.parse (sys.argv)
except OptionError, exc:
except OptionError as exc:
print >> sys.stderr, exc.args[0]
sys.exit (1)

View file

@ -171,7 +171,7 @@ class SaveWriteFile (object):
temp_filename)
try:
os.unlink (temp_filename)
except EnvironmentError, exc:
except EnvironmentError as exc:
self.logger.warning ("deleting stale temporary file "
"failed: %s", exc)
@ -190,7 +190,7 @@ class SaveWriteFile (object):
if self.temp_name:
try:
os.rename (self.temp_name, self.target_name)
except OSError, exc:
except OSError as exc:
import errno
if exc.errno == errno.EEXIST:
# We are probably on windows.
@ -206,7 +206,7 @@ class SaveWriteFile (object):
try:
os.unlink (self.temp_name)
except EnvironmentError, exc:
except EnvironmentError as exc:
self.logger.warning ("deleting temporary file failed: %s", exc)
self.temp_name = None
@ -301,7 +301,7 @@ class DevhelpClient (object):
try:
proc = FixedPopen (("devhelp",) + args,
stdout = PIPE)
except OSError, exc:
except OSError as exc:
self._check_os_error (exc)
raise
@ -318,7 +318,7 @@ class DevhelpClient (object):
try:
proc = FixedPopen (("devhelp",) + args)
except OSError, exc:
except OSError as exc:
self._check_os_error (exc)
raise

View file

@ -419,7 +419,7 @@ class Window (object):
try:
select_index = model.line_index_from_top (selected_index)
except IndexError, exc:
except IndexError as exc:
self.logger.debug ("abs line index %i filtered out, not reselecting",
selected_index)
else:
@ -741,7 +741,7 @@ class Window (object):
self.dispatcher = Common.Data.GSourceDispatcher ()
self.log_file = Data.LogFile (filename, self.dispatcher)
except EnvironmentError, exc:
except EnvironmentError as exc:
try:
file_size = os.path.getsize (filename)
except EnvironmentError:

View file

@ -51,7 +51,7 @@ def main ():
try:
import GstDebugViewer
except ImportError, exc:
except ImportError as exc:
print >> sys.stderr, str (exc)
sys.exit (1)
else: