Index: pygobject-3.1.0/gi/pygi-marshal-from-py.c
===================================================================
--- pygobject-3.1.0.orig/gi/pygi-marshal-from-py.c	2012-02-10 18:26:51.000000000 +0100
+++ pygobject-3.1.0/gi/pygi-marshal-from-py.c	2012-02-10 18:27:07.000000000 +0100
@@ -148,7 +148,7 @@
         return FALSE;
     }
 
-    arg->v_long = long_;
+    arg->v_int8 = long_;
 
     return TRUE;
 }
@@ -197,7 +197,7 @@
         return FALSE;
     }
 
-    arg->v_long = long_;
+    arg->v_uint8 = long_;
 
     return TRUE;
 }
@@ -236,7 +236,7 @@
         return FALSE;
     }
 
-    arg->v_long = long_;
+    arg->v_int16 = long_;
 
     return TRUE;
 }
@@ -275,7 +275,7 @@
         return FALSE;
     }
 
-    arg->v_long = long_;
+    arg->v_uint16 = long_;
 
     return TRUE;
 }
@@ -314,7 +314,7 @@
         return FALSE;
     }
 
-    arg->v_long = long_;
+    arg->v_int32 = long_;
 
     return TRUE;
 }
@@ -359,7 +359,7 @@
         return FALSE;
     }
 
-    arg->v_uint64 = long_;
+    arg->v_uint32 = long_;
 
     return TRUE;
 }
@@ -1044,6 +1044,22 @@
     return TRUE;
 }
 
+static gpointer
+_pygi_arg_to_hash_pointer (const GIArgument *arg,
+                           GITypeTag        type_tag)
+{
+    switch (type_tag) {
+        case GI_TYPE_TAG_INT32:
+            return GINT_TO_POINTER(arg->v_int32);
+        case GI_TYPE_TAG_UTF8:
+        case GI_TYPE_TAG_FILENAME:
+            return arg->v_pointer;
+        default:
+            g_assert_not_reached();
+            return arg->v_pointer;
+    }
+}
+
 gboolean
 _pygi_marshal_from_py_ghash (PyGIInvokeState   *state,
                              PyGICallableCache *callable_cache,
@@ -1131,7 +1147,9 @@
                                        &value))
             goto err;
 
-        g_hash_table_insert (hash_, key.v_pointer, value.v_pointer);
+        g_hash_table_insert (hash_,
+                             _pygi_arg_to_hash_pointer (&key, hash_cache->key_cache->type_tag),
+                             _pygi_arg_to_hash_pointer (&value, hash_cache->value_cache->type_tag));
         continue;
 err:
         /* FIXME: cleanup hash keys and values */
Index: pygobject-3.1.0/gi/pygi-marshal-to-py.c
===================================================================
--- pygobject-3.1.0.orig/gi/pygi-marshal-to-py.c	2012-02-10 18:26:51.000000000 +0100
+++ pygobject-3.1.0/gi/pygi-marshal-to-py.c	2012-02-10 18:27:07.000000000 +0100
@@ -511,6 +511,22 @@
     return py_obj;
 }
 
+static void
+_pygi_hash_pointer_to_arg (GIArgument *arg,
+                           GITypeTag  type_tag)
+{
+    switch (type_tag) {
+        case GI_TYPE_TAG_INT32:
+            arg->v_int32 = GPOINTER_TO_INT(arg->v_pointer);
+            break;
+        case GI_TYPE_TAG_UTF8:
+        case GI_TYPE_TAG_FILENAME:
+            break;
+        default:
+            g_assert_not_reached();
+    }
+}
+
 PyObject *
 _pygi_marshal_to_py_ghash (PyGIInvokeState   *state,
                            PyGICallableCache *callable_cache,
@@ -558,6 +574,8 @@
         PyObject *py_value;
         int retval;
 
+
+        _pygi_hash_pointer_to_arg (&key_arg, hash_cache->key_cache->type_tag);
         py_key = key_to_py_marshaller ( state,
                                       callable_cache,
                                       key_arg_cache,
@@ -568,6 +586,7 @@
             return NULL;
         }
 
+        _pygi_hash_pointer_to_arg (&value_arg, hash_cache->value_cache->type_tag);
         py_value = value_to_py_marshaller ( state,
                                           callable_cache,
                                           value_arg_cache,
Index: pygobject-3.1.0/gi/pygi-argument.c
===================================================================
--- pygobject-3.1.0.orig/gi/pygi-argument.c	2012-02-10 18:28:52.000000000 +0100
+++ pygobject-3.1.0/gi/pygi-argument.c	2012-02-10 18:29:01.000000000 +0100
@@ -722,15 +722,8 @@
             arg.v_boolean = PyObject_IsTrue (object);
             break;
         }
-        case GI_TYPE_TAG_UINT8:
-            if (PYGLIB_PyBytes_Check(object)) {
-                arg.v_long = (long)(PYGLIB_PyBytes_AsString(object)[0]);
-                break;
-            }
-
         case GI_TYPE_TAG_INT8:
         case GI_TYPE_TAG_INT16:
-        case GI_TYPE_TAG_UINT16:
         case GI_TYPE_TAG_INT32:
         {
             PyObject *int_;
@@ -740,12 +733,19 @@
                 break;
             }
 
-            arg.v_long = PYGLIB_PyLong_AsLong (int_);
+            if (type_tag == GI_TYPE_TAG_INT32)
+                arg.v_int32 = PYGLIB_PyLong_AsLong (int_);
+            else if (type_tag == GI_TYPE_TAG_INT8)
+                arg.v_int8 = PYGLIB_PyLong_AsLong (int_);
+            else if (type_tag == GI_TYPE_TAG_INT16)
+                arg.v_int16 = PYGLIB_PyLong_AsLong (int_);
 
             Py_DECREF (int_);
 
             break;
         }
+        case GI_TYPE_TAG_UINT8:
+        case GI_TYPE_TAG_UINT16:
         case GI_TYPE_TAG_UINT32:
         case GI_TYPE_TAG_UINT64:
         {
@@ -764,7 +764,14 @@
 #endif
             value = PyLong_AsUnsignedLongLong (number);
 
-            arg.v_uint64 = value;
+            if (type_tag == GI_TYPE_TAG_UINT32)
+                arg.v_uint32 = value;
+            else if (type_tag == GI_TYPE_TAG_UINT64)
+                arg.v_uint64 = value;
+            else if (type_tag == GI_TYPE_TAG_UINT8)
+                arg.v_uint8 = value;
+            else if (type_tag == GI_TYPE_TAG_UINT16)
+                arg.v_uint16 = value;
 
             Py_DECREF (number);
 
