Python binding default string type
Simon McVittie
simon.mcvittie at collabora.co.uk
Fri Mar 21 14:13:48 PDT 2008
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Fri, 21 Mar 2008 at 12:24:22 +0000, Tristan Hill wrote:
> I am updating an application using the 0.71 python dbus bindings to
> 0.82. Several places are receiving a signal and use a caching layer
> that could eventually pickle the received value to disk. Now that
> string values are dbus.String's pickle will complain when dumping to
> disk.
>
> Is it recommended that I convert to a str in each signal receiver or can
> I make the bindings return a picklable string?
dbus.String is a subclass of unicode, not str, so use unicode(the_string)
(or the_string.encode('utf-8') if you prefer) if you want to pickle it.
You can select dbus.UTF8String (a str subclass), but neither String nor
UTF8String is pickleable (patches welcome).
Simon
-----BEGIN PGP SIGNATURE-----
iD8DBQFH5CUMWSc8zVUw7HYRAgFwAKC2fnLW0xuJm5gAVFGMu4IOtSwgCACgsvpA
06QErj043SgjGoX9rqwf2n8=
=0/7T
-----END PGP SIGNATURE-----
More information about the dbus
mailing list