From 14225c74b5bd75cf6c4cda3647341dc20214e6b8 Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Tue, 13 Dec 2011 11:55:44 +0000 Subject: Use Python 3 syntax to catch exceptions Signed-off-by: Simon McVittie --- dbus/_expat_introspect_parser.py | 2 +- dbus/bus.py | 2 +- dbus/connection.py | 6 +++--- dbus/proxies.py | 2 +- dbus/service.py | 6 +++--- 5 files changed, 9 insertions(+), 9 deletions(-) (limited to 'dbus') diff --git a/dbus/_expat_introspect_parser.py b/dbus/_expat_introspect_parser.py index 96b27ad..de38c45 100644 --- a/dbus/_expat_introspect_parser.py +++ b/dbus/_expat_introspect_parser.py @@ -81,5 +81,5 @@ def process_introspection_data(data): """ try: return _Parser().parse(data) - except Exception, e: + except Exception as e: raise IntrospectionParserException('%s: %s' % (e.__class__, e)) diff --git a/dbus/bus.py b/dbus/bus.py index 86c655d..6f775de 100644 --- a/dbus/bus.py +++ b/dbus/bus.py @@ -176,7 +176,7 @@ class BusConnection(Connection): and bus_name != BUS_DAEMON_NAME): try: return self.get_name_owner(bus_name) - except DBusException, e: + except DBusException as e: if e.get_dbus_name() != _NAME_HAS_NO_OWNER: raise # else it doesn't exist: try to start it diff --git a/dbus/connection.py b/dbus/connection.py index d76aaf2..10f03c7 100644 --- a/dbus/connection.py +++ b/dbus/connection.py @@ -525,7 +525,7 @@ class Connection(_Connection): for cb in self.__call_on_disconnection: try: cb(self) - except Exception, e: + except Exception as e: # basicConfig is a no-op if logging is already configured logging.basicConfig() _logger.error('Exception in handler for Disconnected ' @@ -564,7 +564,7 @@ class Connection(_Connection): # Add the arguments to the function try: message.append(signature=signature, *args) - except Exception, e: + except Exception as e: logging.basicConfig() _logger.error('Unable to set arguments %r according to ' 'signature %r: %s: %s', @@ -618,7 +618,7 @@ class Connection(_Connection): # Add the arguments to the function try: message.append(signature=signature, *args) - except Exception, e: + except Exception as e: logging.basicConfig() _logger.error('Unable to set arguments %r according to ' 'signature %r: %s: %s', diff --git a/dbus/proxies.py b/dbus/proxies.py index bf99a1c..51d8d9f 100644 --- a/dbus/proxies.py +++ b/dbus/proxies.py @@ -388,7 +388,7 @@ class ProxyObject(object): try: try: self._introspect_method_map = process_introspection_data(data) - except IntrospectionParserException, e: + except IntrospectionParserException as e: self._introspect_error_handler(e) return diff --git a/dbus/service.py b/dbus/service.py index b92d840..f1b3a9b 100644 --- a/dbus/service.py +++ b/dbus/service.py @@ -250,12 +250,12 @@ def _method_reply_return(connection, message, method_name, signature, *retval): reply = MethodReturnMessage(message) try: reply.append(signature=signature, *retval) - except Exception, e: + except Exception as e: logging.basicConfig() if signature is None: try: signature = reply.guess_signature(retval) + ' (guessed)' - except Exception, e: + except Exception as e: _logger.error('Unable to guess signature for arguments %r: ' '%s: %s', retval, e.__class__, e) raise @@ -743,7 +743,7 @@ class Object(Interface): retval = (retval,) _method_reply_return(connection, message, method_name, signature, *retval) - except Exception, exception: + except Exception as exception: # send error reply _method_reply_error(connection, message, exception) -- cgit v1.2.3