From caf583ef47fc28e79b817dd4b9cbf8ca5b1e53e1 Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Wed, 27 Oct 2010 10:47:26 +0800 Subject: [PATCH] modified: dbus/_expat_introspect_parser.py modified: dbus/bus.py modified: dbus/connection.py modified: dbus/decorators.py modified: dbus/proxies.py modified: dbus/service.py Fix python exceptions to conform to Python 3.x requirements --- dbus/_expat_introspect_parser.py | 2 +- dbus/bus.py | 2 +- dbus/connection.py | 6 +++--- dbus/decorators.py | 8 ++++---- dbus/proxies.py | 2 +- dbus/service.py | 6 +++--- 6 files changed, 13 insertions(+), 13 deletions(-) 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 edd5ef7..98dfd66 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/decorators.py b/dbus/decorators.py index a5ca281..71a7203 100644 --- a/dbus/decorators.py +++ b/dbus/decorators.py @@ -182,9 +182,9 @@ def method(dbus_interface, in_signature=None, out_signature=None, in_sig = tuple(Signature(in_signature)) if len(in_sig) > len(args): - raise ValueError, 'input signature is longer than the number of arguments taken' + raise ValueError('input signature is longer than the number of arguments taken') elif len(in_sig) < len(args): - raise ValueError, 'input signature is shorter than the number of arguments taken' + raise ValueError('input signature is shorter than the number of arguments taken') func._dbus_is_method = True func._dbus_async_callbacks = async_callbacks @@ -325,9 +325,9 @@ def signal(dbus_interface, signature=None, path_keyword=None, sig = tuple(Signature(signature)) if len(sig) > len(args): - raise ValueError, 'signal signature is longer than the number of arguments provided' + raise ValueError('signal signature is longer than the number of arguments provided') elif len(sig) < len(args): - raise ValueError, 'signal signature is shorter than the number of arguments provided' + raise ValueError('signal signature is shorter than the number of arguments provided') emit_signal.__name__ = func.__name__ emit_signal.__doc__ = func.__doc__ diff --git a/dbus/proxies.py b/dbus/proxies.py index cbb5d53..63aa3c7 100644 --- a/dbus/proxies.py +++ b/dbus/proxies.py @@ -382,7 +382,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) -- 1.7.1