[pygobject] Fix marshalling of GByteArrays



commit b800a6903300dbe9435ed8eb3677eb9c0536ec31
Author: Martin Pitt <martinpitt gnome org>
Date:   Fri Nov 9 16:02:00 2012 +0100

    Fix marshalling of GByteArrays
    
    In _pygi_marshal_from_py_array(), set the array length after copying the data
    in the GI_TYPE_TAG_UINT8 case (which applies for GByteArrays), otherwise it
    will always come out as zero length.
    
    Enable the TestGByteArray.test_bytearray_none_in() test case as that works now.

 gi/pygi-marshal-from-py.c |    1 +
 tests/test_gi.py          |    3 +--
 2 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/gi/pygi-marshal-from-py.c b/gi/pygi-marshal-from-py.c
index d0e96db..c20e023 100644
--- a/gi/pygi-marshal-from-py.c
+++ b/gi/pygi-marshal-from-py.c
@@ -930,6 +930,7 @@ _pygi_marshal_from_py_array (PyGIInvokeState   *state,
     if (sequence_cache->item_cache->type_tag == GI_TYPE_TAG_UINT8 &&
         PYGLIB_PyBytes_Check (py_arg)) {
         memcpy(array_->data, PYGLIB_PyBytes_AsString (py_arg), length);
+        array_->len = length;
         if (sequence_cache->is_zero_terminated) {
             /* If array_ has been created with zero_termination, space for the
              * terminator is properly allocated, so we're not off-by-one here. */
diff --git a/tests/test_gi.py b/tests/test_gi.py
index 843a6b6..f65cf74 100644
--- a/tests/test_gi.py
+++ b/tests/test_gi.py
@@ -1022,8 +1022,7 @@ class TestGByteArray(unittest.TestCase):
     def test_bytearray_full_return(self):
         self.assertEqual(b'\x001\xFF3', GIMarshallingTests.bytearray_full_return())
 
-    # FIXME: we do not currently support marshalling GByteArrays
-    def disabled_test_bytearray_none_in(self):
+    def test_bytearray_none_in(self):
         GIMarshallingTests.bytearray_none_in(b'\x00\x31\xFF\x33')
 
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]