diff options
author | Simon Feltman <sfeltman@src.gnome.org> | 2013-07-22 23:24:13 -0700 |
---|---|---|
committer | Simon Feltman <sfeltman@src.gnome.org> | 2013-07-25 17:02:12 -0700 |
commit | f517bfbc134b78a23b754332e59b9bb67bb68e98 (patch) | |
tree | 18528ea282e45c04f9a2213fe653671e62dedcdd /gi | |
parent | fe9df90531f3dd04c0d13d73ebd4ae7dd396c9b1 (diff) | |
download | pygobject-f517bfbc134b78a23b754332e59b9bb67bb68e98.tar.gz |
Add support for PyBytes with int8 and uint8 from Python marshaler
This additional type marshaling is necessary for unifying marhalers
due to the same feature being available with cached argument marshaling.
https://bugzilla.gnome.org/show_bug.cgi?id=693405
Diffstat (limited to 'gi')
-rw-r--r-- | gi/pygi-marshal-from-py.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/gi/pygi-marshal-from-py.c b/gi/pygi-marshal-from-py.c index fdf13af1..5f360bd5 100644 --- a/gi/pygi-marshal-from-py.c +++ b/gi/pygi-marshal-from-py.c @@ -1015,6 +1015,20 @@ _pygi_marshal_from_py_basic_type (PyObject *object, /* in */ break; case GI_TYPE_TAG_INT8: case GI_TYPE_TAG_UINT8: + if (PYGLIB_PyBytes_Check (object)) { + if (PYGLIB_PyBytes_Size (object) != 1) { + PyErr_Format (PyExc_TypeError, "Must be a single character"); + return FALSE; + } + if (type_tag == GI_TYPE_TAG_INT8) { + arg->v_int8 = (gint8)(PYGLIB_PyBytes_AsString (object)[0]); + } else { + arg->v_uint8 = (guint8)(PYGLIB_PyBytes_AsString (object)[0]); + } + } else { + return _pygi_marshal_from_py_long (object, arg, type_tag, transfer); + } + break; case GI_TYPE_TAG_INT16: case GI_TYPE_TAG_UINT16: case GI_TYPE_TAG_INT32: |