Patch to expose Marshal and Demarshal in the Python API
Submitted by Ben Schwartz
Assigned to Simon McVittie
Description
Created attachment 22205 A patch to message.c to add marshal() and demarshal() methods
I would like to have dbus_message_marshal and dbus_message_demarshal available through dbus-python. As such, I attempted to write a patch. The patch is attached. Marshaling seems to work, but demarshaling does not. Here's an example python session:
import dbus x = dbus.lowlevel.SignalMessage('/a/b','c.d','e') x.append('a test string') s = x.marshal() s 'l\x04\x01\x01\x00\x00\x00\x00\x00\x00\x00\x007\x00\x00\x00\x01\x01o\x00\x04\x00\x00\x00/a/b\x00\x00\x00\x00\x02\x01s\x00\x03\x00\x00\x00c.d\x00\x00\x00\x00\x00\x03\x01s\x00\x01\x00\x00\x00e\x00\x00\x00\x00\x00\x00\x00\x08\x01g\x00\x01s\x00\x00\r\x00\x00\x00a test string\x00' dbus.lowlevel.Message.demarshal(s) Traceback (most recent call last): File "
<stdin>
", line 1, in<module>
RuntimeError: Message is corrupted
I have tested extensively to ensure that the string being produced by dbus_message_marshal is precisely identical to the one being provided to dbus_message_demarshal. Therefore, I have no idea what the problem is. My current estimation is that, possibly, dbus_message_demarshal has stricter validation requirements than dbus_message_marshal, and the message "x" in this example meets the marshaling requirements but not the demarshaling requirements.
Anyway, please advise. I would like to get this patch tested, working, submitted, and included.
Patch 22205, "A patch to message.c to add marshal() and demarshal() methods":
test.patch