Comment 21 for bug 893091

Revision history for this message
In , Johnp-redhat (johnp-redhat) wrote :

(In reply to comment #14)

> (In reply to comment #13)
> > Since dbus specifies that signatures, object_paths, service names, etc. are all
> > ascii I have decided to make them all subclass the Bytes type.
>
> I don't think that's right; they should all subclass str, the normal Python
> string type (which happens to be Unicode on Python 3).

Easy enough to do but it entails doing something like this every time we want to access the raw char pointer:

PyObject *sig_utf8 = PyUnicode_AsUTF8String(sig);
char *signature = PyBytes_AsString(sig_utf8);
/*do something with signature */
Py_DECREF(signature);

> However, dbus.UTF8String should be a deprecated subtype of bytes when running
> on Python 3, and dbus.ByteArray should be a subtype of bytes.

Ok.

> It's probably also worth setting byte_arrays=True by default in Python 3 (the
> ability to use a dbus.Array of dbus.Byte is almost never useful), and it might
> even be worth removing utf8_strings and UTF8String altogether.

I think this is a good idea to simplify things.

What do you think about the change to subtyping from Long on both 2.x and 3.x which gets rid of any Int calls. It passes the test suite.