summaryrefslogtreecommitdiff
path: root/_dbus_bindings
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2011-12-15 16:50:02 -0500
committerBarry Warsaw <barry@python.org>2011-12-15 16:50:02 -0500
commitf2909c23abc4f8fa55d71673785f8e70a843f6ce (patch)
tree97adb74ab2ae9f262cd6ad11e049e50c86f1f178 /_dbus_bindings
parent4c1c2eade1c5b383adad94a7a4fd6553873fecf0 (diff)
- Added back the missing PY3PORT.rst file, with updates.
- Disallow appending unicode objects with 'y' (bytes) signatures. This now requires either a bytes object or an integer. Update the tests to reflect - this change. - Fix broken __all__ in Python 3.
Diffstat (limited to '_dbus_bindings')
-rw-r--r--_dbus_bindings/message-append.c26
1 files changed, 6 insertions, 20 deletions
diff --git a/_dbus_bindings/message-append.c b/_dbus_bindings/message-append.c
index c08f498..bbf1286 100644
--- a/_dbus_bindings/message-append.c
+++ b/_dbus_bindings/message-append.c
@@ -587,35 +587,21 @@ _message_iter_append_byte(DBusMessageIter *appender, PyObject *obj)
if (PyBytes_Check(obj)) {
if (PyBytes_GET_SIZE(obj) != 1) {
- PyErr_Format(PyExc_ValueError, "Expected a string of "
- "length 1 byte, but found %d bytes",
- (int) PyBytes_GET_SIZE(obj));
+ PyErr_Format(PyExc_ValueError,
+ "Expected a length-1 bytes but found %d bytes",
+ (int)PyBytes_GET_SIZE(obj));
return -1;
}
y = *(unsigned char *)PyBytes_AS_STRING(obj);
}
- else if (PyUnicode_Check(obj)) {
- PyObject *obj_as_bytes = PyUnicode_AsUTF8String(obj);
-
- if (!obj_as_bytes)
- return -1;
- if (PyBytes_GET_SIZE(obj_as_bytes) != 1) {
- PyErr_Format(PyExc_ValueError, "Expected a string of "
- "length 1 byte, but found %d bytes",
- (int)PyBytes_GET_SIZE(obj_as_bytes));
- Py_CLEAR(obj_as_bytes);
- return -1;
- }
- y = *(unsigned char *)PyBytes_AS_STRING(obj_as_bytes);
- Py_CLEAR(obj_as_bytes);
- }
else {
long i = PyLong_AsLong(obj);
if (i == -1 && PyErr_Occurred()) return -1;
if (i < 0 || i > 0xff) {
- PyErr_Format(PyExc_ValueError, "%d outside range for a "
- "byte value", (int)i);
+ PyErr_Format(PyExc_ValueError,
+ "%d outside range for a byte value",
+ (int)i);
return -1;
}
y = i;