diff options
| author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2012-01-11 14:03:53 +0000 |
|---|---|---|
| committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2012-01-11 14:03:53 +0000 |
| commit | 69342f86b0d036ca41a19363efaf4e8352837c24 (patch) | |
| tree | 411e3f328188590eaa14f3959bf07ec67d958e54 /_dbus_bindings | |
| parent | cada4883df6b67f4059eedd2def1f5cffa41c7d8 (diff) | |
| download | dbus-python-69342f86b0d036ca41a19363efaf4e8352837c24.tar.gz | |
Do not allow Byte(unicode(x)) (i.e. Byte(str(x)) in Python 3)
Unicode strings aren't bytestrings, so there's no obvious meaning for
the byte value of a Unicode string of length 1.
Diffstat (limited to '_dbus_bindings')
| -rw-r--r-- | _dbus_bindings/bytes.c | 14 |
1 files changed, 0 insertions, 14 deletions
diff --git a/_dbus_bindings/bytes.c b/_dbus_bindings/bytes.c index 548ca46..e053f43 100644 --- a/_dbus_bindings/bytes.c +++ b/_dbus_bindings/bytes.c @@ -96,20 +96,6 @@ Byte_new(PyTypeObject *cls, PyObject *args, PyObject *kwargs) if (!obj) goto bad_arg; } - else if (PyUnicode_Check(obj)) { - PyObject *obj_as_bytes = PyUnicode_AsUTF8String(obj); - if (!obj_as_bytes) - return NULL; - if (PyBytes_GET_SIZE(obj_as_bytes) != 1) { - Py_CLEAR(obj_as_bytes); - goto bad_arg; - } - obj = PyLong_FromLong( - (unsigned char)PyBytes_AS_STRING(obj_as_bytes)[0]); - Py_CLEAR(obj_as_bytes); - if (!obj) - goto bad_arg; - } else if (PyLong_Check(obj) #ifndef PY3 || PyInt_Check(obj) |
