diff options
author | Barry Warsaw <barry@python.org> | 2011-12-14 13:36:39 -0500 |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2011-12-14 13:36:39 -0500 |
commit | 71f4481c1876785572170ef68d5624ed23f91333 (patch) | |
tree | 5b7fc38bdbf9294242acb736a3b3125e4eb9ce23 /_dbus_bindings/bytes.c | |
parent | ca7a705663adbac2e781d10c13fc98a5444ef646 (diff) | |
download | dbus-python-71f4481c1876785572170ef68d5624ed23f91333.tar.gz |
In preparation for Python 3 support, use the Python 2 PyBytes aliases for the
PyString API. This makes the code compilable in Python 2.x (x >= 6) and
Python 3.
Diffstat (limited to '_dbus_bindings/bytes.c')
-rw-r--r-- | _dbus_bindings/bytes.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/_dbus_bindings/bytes.c b/_dbus_bindings/bytes.c index e06dcd1..e608ec2 100644 --- a/_dbus_bindings/bytes.c +++ b/_dbus_bindings/bytes.c @@ -79,12 +79,12 @@ Byte_new(PyTypeObject *cls, PyObject *args, PyObject *kwargs) /* obj is only a borrowed ref for the moment */ obj = PyTuple_GetItem(args, 0); - if (PyString_Check(obj)) { + if (PyBytes_Check(obj)) { /* string of length 1, we hope */ - if (PyString_GET_SIZE(obj) != 1) { + if (PyBytes_GET_SIZE(obj) != 1) { goto bad_arg; } - obj = PyInt_FromLong((unsigned char)(PyString_AS_STRING(obj)[0])); + obj = PyInt_FromLong((unsigned char)(PyBytes_AS_STRING(obj)[0])); } else if (PyInt_Check(obj)) { long i = PyInt_AS_LONG(obj); @@ -123,7 +123,7 @@ static PyObject * Byte_tp_str(PyObject *self) { unsigned char str[2] = { (unsigned char)PyInt_AS_LONG(self), 0 }; - return PyString_FromStringAndSize((char *)str, 1); + return PyBytes_FromStringAndSize((char *)str, 1); } PyTypeObject DBusPyByte_Type = { |