diff options
author | Barry Warsaw <barry@python.org> | 2011-12-15 06:57:21 -0500 |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2011-12-15 06:57:21 -0500 |
commit | 4c1c2eade1c5b383adad94a7a4fd6553873fecf0 (patch) | |
tree | b9e0f45fc19539bcaddff69e661bf0c5d21bab5a /dbus/decorators.py | |
parent | 667082d0b4aef9c438a2e7fec89614b5b8ef960a (diff) |
This is the big one; it adds Python 3 support.
Diffstat (limited to 'dbus/decorators.py')
-rw-r--r-- | dbus/decorators.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/dbus/decorators.py b/dbus/decorators.py index 71a7203..b164582 100644 --- a/dbus/decorators.py +++ b/dbus/decorators.py @@ -33,14 +33,15 @@ import inspect from dbus import validate_interface_name, Signature, validate_member_name from dbus.lowlevel import SignalMessage from dbus.exceptions import DBusException +from dbus._compat import is_py2 def method(dbus_interface, in_signature=None, out_signature=None, - async_callbacks=None, - sender_keyword=None, path_keyword=None, destination_keyword=None, - message_keyword=None, connection_keyword=None, - utf8_strings=False, byte_arrays=False, - rel_path_keyword=None): + async_callbacks=None, + sender_keyword=None, path_keyword=None, destination_keyword=None, + message_keyword=None, connection_keyword=None, + byte_arrays=False, + rel_path_keyword=None, **kwargs): """Factory for decorators used to mark methods of a `dbus.service.Object` to be exported on the D-Bus. @@ -198,8 +199,12 @@ def method(dbus_interface, in_signature=None, out_signature=None, func._dbus_message_keyword = message_keyword func._dbus_connection_keyword = connection_keyword func._dbus_args = args - func._dbus_get_args_options = {'byte_arrays': byte_arrays, - 'utf8_strings': utf8_strings} + func._dbus_get_args_options = dict(byte_arrays=byte_arrays) + if is_py2: + func._dbus_get_args_options['utf8_strings'] = kwargs.get( + 'utf8_strings', False) + elif 'utf8_strings' in kwargs: + raise TypeError("unexpected keyword argument 'utf8_strings'") return func return decorator |