From 7a05a716d26a14fb8a46d4de11945064d2a058a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Stadler?= Date: Wed, 16 Nov 2011 19:45:16 +0100 Subject: [PATCH] Switch to new try..except syntax This is forward compatible to Python 3. --- debug-viewer/GstDebugViewer/Common/Main.py | 6 +++--- debug-viewer/GstDebugViewer/Common/utils.py | 10 +++++----- debug-viewer/GstDebugViewer/GUI/window.py | 4 ++-- debug-viewer/gst-debug-viewer | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/debug-viewer/GstDebugViewer/Common/Main.py b/debug-viewer/GstDebugViewer/Common/Main.py index 4fad0ee087..1cb1c7edf9 100644 --- a/debug-viewer/GstDebugViewer/Common/Main.py +++ b/debug-viewer/GstDebugViewer/Common/Main.py @@ -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) diff --git a/debug-viewer/GstDebugViewer/Common/utils.py b/debug-viewer/GstDebugViewer/Common/utils.py index c7466e7151..fd60a8fea8 100644 --- a/debug-viewer/GstDebugViewer/Common/utils.py +++ b/debug-viewer/GstDebugViewer/Common/utils.py @@ -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 diff --git a/debug-viewer/GstDebugViewer/GUI/window.py b/debug-viewer/GstDebugViewer/GUI/window.py index 2a82aa928f..12e44ce016 100644 --- a/debug-viewer/GstDebugViewer/GUI/window.py +++ b/debug-viewer/GstDebugViewer/GUI/window.py @@ -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: diff --git a/debug-viewer/gst-debug-viewer b/debug-viewer/gst-debug-viewer index dff1b920b4..4a225122b9 100755 --- a/debug-viewer/gst-debug-viewer +++ b/debug-viewer/gst-debug-viewer @@ -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: