diff options
| author | Robert McQueen <robot101@debian.org> | 2005-10-24 18:29:50 +0000 | 
|---|---|---|
| committer | Robert McQueen <robot101@debian.org> | 2005-10-24 18:29:50 +0000 | 
| commit | ef47e01f7593c4844f927752c0462dae7722ff9e (patch) | |
| tree | a8e947d38bf380c71566d21c7e79d6636dfcb1f2 | |
| parent | 396b9c9e709f9abd6906a962382df409e118a48c (diff) | |
2005-10-24  Robert McQueen <robot101@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
| -rw-r--r-- | ChangeLog | 14 | ||||
| -rw-r--r-- | python/dbus_bindings.pyx | 16 | ||||
| -rw-r--r-- | python/introspect_parser.py | 2 | ||||
| -rw-r--r-- | test/data/valid-service-files/.cvsignore | 3 | ||||
| -rw-r--r-- | test/python/.cvsignore | 2 | ||||
| -rwxr-xr-x | test/python/test-client.py | 2 | 
6 files changed, 30 insertions, 9 deletions
| @@ -1,3 +1,17 @@ +2005-10-24  Robert McQueen <robot101@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 +  2005-10-17  John (J5) Palmieri  <johnp@redhat.com>  	* glib/dbus-gvalue-utils.c (hash_free_from_gtype): handle gdouble diff --git a/python/dbus_bindings.pyx b/python/dbus_bindings.pyx index f7c88006..4bf0893c 100644 --- a/python/dbus_bindings.pyx +++ b/python/dbus_bindings.pyx @@ -123,9 +123,9 @@ class Double(float):      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 @@ cdef class MessageIter:      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 @@ cdef class MessageIter:          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 @@ cdef class MessageIter:              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 @@ cdef class MessageIter:      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 diff --git a/python/introspect_parser.py b/python/introspect_parser.py index 6e94cccf..40cae1e7 100644 --- a/python/introspect_parser.py +++ b/python/introspect_parser.py @@ -8,7 +8,7 @@ def process_introspection_data(data):      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") diff --git a/test/data/valid-service-files/.cvsignore b/test/data/valid-service-files/.cvsignore index ca3fbc75..b6f2adcf 100644 --- a/test/data/valid-service-files/.cvsignore +++ b/test/data/valid-service-files/.cvsignore @@ -1,5 +1,6 @@  debug-echo.service -debug-segfault.service  debug-glib.service +debug-python.service +debug-segfault.service  debug-shell-echo-fail.service  debug-shell-echo-success.service diff --git a/test/python/.cvsignore b/test/python/.cvsignore new file mode 100644 index 00000000..282522db --- /dev/null +++ b/test/python/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/test/python/test-client.py b/test/python/test-client.py index 57965cc7..3cc1542b 100755 --- a/test/python/test-client.py +++ b/test/python/test-client.py @@ -23,6 +23,8 @@ if not dbus_bindings.__file__.startswith(pydir):  test_types_vals = [1, 12323231, 3.14159265, 99999999.99,                   "dude", "123", "What is all the fuss about?", "gob@gob.com", +                 u'\\u310c\\u310e\\u3114', u'\\u0413\\u0414\\u0415', +                 u'\\u2200software \\u2203crack', u'\\xf4\\xe5\\xe8',                   [1,2,3], ["how", "are", "you"], [1.23,2.3], [1], ["Hello"],                   (1,2,3), (1,), (1,"2",3), ("2", "what"), ("you", 1.2),                   {1:"a", 2:"b"}, {"a":1, "b":2}, #{"a":(1,"B")}, | 
