Index: gobject/pygobject.c
===================================================================
--- gobject/pygobject.c	(revision 779)
+++ gobject/pygobject.c	(working copy)
@@ -1279,28 +1279,30 @@
     Py_ssize_t      pos;
     PyObject        *value;
     PyObject        *key;
+    PyObject        *result = NULL;
 
     CHECK_GOBJECT(self);
 
     class = G_OBJECT_GET_CLASS(self->obj);
     
     g_object_freeze_notify (G_OBJECT(self->obj));
+    pyg_begin_allow_threads;
     pos = 0;
 
     while (kwargs && PyDict_Next (kwargs, &pos, &key, &value)) {
-    gchar *key_str = PyString_AsString (key);
-    GParamSpec *pspec;
-    GValue gvalue ={ 0, };
+        gchar *key_str = PyString_AsString (key);
+        GParamSpec *pspec;
+        GValue gvalue = { 0, };
 
-    pspec = g_object_class_find_property (class, key_str);
-    if (!pspec) {
+        pspec = g_object_class_find_property (class, key_str);
+        if (!pspec) {
 	    gchar buf[512];
 
 	    g_snprintf(buf, sizeof(buf),
 		       "object `%s' doesn't support property `%s'",
 		       g_type_name(G_OBJECT_TYPE(self->obj)), key_str);
 	    PyErr_SetString(PyExc_TypeError, buf);
-	    return NULL;
+            goto exit;
 	}
 
 	g_value_init(&gvalue, G_PARAM_SPEC_VALUE_TYPE(pspec));
@@ -1310,16 +1312,20 @@
 	    g_snprintf(buf, sizeof(buf),
 		       "could not convert value for property `%s'", key_str);
 	    PyErr_SetString(PyExc_TypeError, buf);
-	    return NULL;
+            goto exit;
 	}
 	g_object_set_property(G_OBJECT(self->obj), key_str, &gvalue);
 	g_value_unset(&gvalue);
     }
 
+    result = Py_None;
+
+ exit:
+    pyg_end_allow_threads;
     g_object_thaw_notify (G_OBJECT(self->obj));
 
-    Py_INCREF(Py_None);
-    return Py_None;
+    Py_XINCREF(result);
+    return result;
 }
 
 static PyObject *
