--- a/gobject/pygobject.c
+++ b/gobject/pygobject.c
@@ -991,7 +991,9 @@ pygobject_new(GObject *obj)
 PyObject *
 pygobject_new_sunk(GObject *obj)
 {
-    g_object_set_qdata (obj, pygobject_ref_sunk_key, GINT_TO_POINTER (1));
+    if (obj)   
+       g_object_set_qdata (obj, pygobject_ref_sunk_key, GINT_TO_POINTER (1));
+       
     return pygobject_new_full(obj, TRUE, NULL);
 }
 
