[PATCH] fix unicode string encoding/decoding in python bindings

John (J5) Palmieri johnp at redhat.com
Wed Sep 21 11:19:54 PDT 2005


I call it D-Bus but there are a couple of permutations.  As for the
patch:

@@ -735,8 +735,9 @@ cdef class MessageIter:
     def get_string(self):
         cdef char *c_str
         dbus_message_iter_get_basic(self.iter, <char **>&c_str)
+        ret = c_str.decode('utf8')

Is that right?  c_str is typed as a char * and is not a python object.
Does Pyrex allow this operation on char * types?  Other than that it
looks good.


On Wed, 2005-09-21 at 12:24 +0100, Robert McQueen wrote:
> I ran into TypeError exceptions when trying to send unicode strings over
> DBus[1] with the python bindings, so I did this patch to add support for
> sending and recieving unicode strings. dbus.String is now descended from
> unicode rather than str, these and str/unicode objects are encoded to
> utf8 to send, and incoming strings are decoded from utf8.
> 
> Regards,
> Rob
> 
> [1]: What's the canonical capitalisation of this? dbus, D-BUS, DBUS,
> DBus, D-Bus...? :)
> _______________________________________________
> dbus mailing list
> dbus at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dbus
-- 
John (J5) Palmieri <johnp at redhat.com>



More information about the dbus mailing list