dbus/python dbus_bindings.pyx, 1.11, 1.12 introspect_parser.py, 1.1,
1.2
Robert McQueen
robot101 at freedesktop.org
Mon Oct 24 11:29:52 PDT 2005
Update of /cvs/dbus/dbus/python
In directory gabe:/tmp/cvs-serv26316/python
Modified Files:
dbus_bindings.pyx introspect_parser.py
Log Message:
2005-10-24 Robert McQueen <robot101 at debian.org>
* python/dbus_bindings.pyx (String, MessageIter): make D-Bus strings
derive from unicode instead of str, and encode/decode UTF-8 when
marshalling/unmarshalling bus messages
* python/introspect_parser.py: encode introspection data as UTF-8
before passing the buffer into libxml2
* test/python/test-client.py: add unicode test strings
* test/data/valid-service-files/.cvsignore, test/python/.cvsignore:
ignore generated python test files
Index: dbus_bindings.pyx
===================================================================
RCS file: /cvs/dbus/dbus/python/dbus_bindings.pyx,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- dbus_bindings.pyx 18 Oct 2005 04:38:04 -0000 1.11
+++ dbus_bindings.pyx 24 Oct 2005 18:29:50 -0000 1.12
@@ -123,9 +123,9 @@
def __init__(self, value):
float.__init__(self, value)
-class String(str):
+class String(unicode):
def __init__(self, value):
- str.__init__(self, value)
+ unicode.__init__(self, value)
class Array(list):
def __init__(self, value, type=None, signature=None):
@@ -733,8 +733,9 @@
def get_string(self):
cdef char *c_str
dbus_message_iter_get_basic(self.iter, <char **>&c_str)
+ ret = c_str.decode('utf8')
- return c_str
+ return ret
def get_object_path(self):
object_path_string = self.get_string()
@@ -836,7 +837,7 @@
elif ptype == long:
ret = TYPE_INT64
ret = str(chr(ret))
- elif ptype == str:
+ elif (ptype == str or ptype == unicode):
ret = TYPE_STRING
ret = str(chr(ret))
elif ptype == float:
@@ -1042,7 +1043,7 @@
retval = self.append_int32(value)
elif value_type == long:
retval = self.append_int64(value)
- elif value_type == str:
+ elif (value_type == str or value_type == unicode):
retval = self.append_string(value)
elif value_type == float:
retval = self.append_double(value)
@@ -1146,8 +1147,9 @@
def append_string(self, value):
cdef char *c_value
- c_value = value
- return dbus_message_iter_append_basic(self.iter, TYPE_STRING, <char **>&c_value)
+ tmp = value.encode('utf8')
+ c_value = tmp
+ return dbus_message_iter_append_basic(self.iter, TYPE_STRING, <char **>&c_value)
def append_object_path(self, value):
cdef char *c_value
Index: introspect_parser.py
===================================================================
RCS file: /cvs/dbus/dbus/python/introspect_parser.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- introspect_parser.py 6 Oct 2005 04:43:52 -0000 1.1
+++ introspect_parser.py 24 Oct 2005 18:29:50 -0000 1.2
@@ -8,7 +8,7 @@
XMLREADER_START_ELEMENT_NODE_TYPE = 1
XMLREADER_END_ELEMENT_NODE_TYPE = 15
- stream = cStringIO.StringIO(data)
+ stream = cStringIO.StringIO(data.encode('utf-8'))
input_source = libxml2.inputBuffer(stream)
reader = input_source.newTextReader("urn:introspect")
More information about the dbus-commit
mailing list