summaryrefslogtreecommitdiff
path: root/dbus/exceptions.py
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2011-12-16 17:07:07 -0500
committerBarry Warsaw <barry@python.org>2011-12-16 17:07:07 -0500
commitf8dab5af0bef5d26a51df41a564a5285c16a9cb5 (patch)
tree9d831ed9d22850f573d4d305365c09f798bcbece /dbus/exceptions.py
parent2167b305db78b8345b0f5ea23bfa445fa7cfca4d (diff)
downloaddbus-python-f8dab5af0bef5d26a51df41a564a5285c16a9cb5.tar.gz
More Python 3 porting, this time primarily to get test-client.py working.
Changes include: - DBusException.get_dbus_message(): In Python 3, the str of the exception will already be a unicode, so don't try to decode it unless it's a bytes object (a.k.a. 8-bit str in Python 2). - gobject_service.py: Switch to pygi and rewrite the metaclass instantiation code to be portable between Python 2 and Python 3. - run-test.sh: echo a few more useful environment variables - test-client.py: - Globally replace deprecated assertEquals with assertEqual - Globally replace deprecated assert_ with assertTrue - Use bytes objects for both 'ay' signatured methods on the server - AcceptUnicodeString will return a native unicode, i.e. a str in Python 3 and a unicode in Python 2. Python 3 has no `unicode` built-in. - Reformat some long lines for debugging. - test-service.py: - Open the log file in 'a' mode for easier tailing. - AcceptUnicodeString will return a native unicode, i.e. a str in Python 3 and a unicode in Python 2. Python 3 has no `unicode` built-in. - reformat some long lines for debugging. - Put module-scope code into a main() function and add a bunch of logger output for better debugging. `session_bus` must still be global though. Wrap main() in a bit try/except to log all top-level exceptions.
Diffstat (limited to 'dbus/exceptions.py')
-rw-r--r--dbus/exceptions.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/dbus/exceptions.py b/dbus/exceptions.py
index 8d84a29..5283369 100644
--- a/dbus/exceptions.py
+++ b/dbus/exceptions.py
@@ -27,6 +27,7 @@ __all__ = ('DBusException', 'MissingErrorHandlerException',
'IntrospectionParserException', 'UnknownMethodException',
'NameExistsException')
+
class DBusException(Exception):
include_traceback = False
@@ -57,7 +58,9 @@ class DBusException(Exception):
def get_dbus_message(self):
s = Exception.__str__(self)
- return s.decode('utf-8', 'replace')
+ if isinstance(s, bytes):
+ return s.decode('utf-8', 'replace')
+ return s
def get_dbus_name(self):
return self._dbus_error_name