Index: gobject/pygtype.c
===================================================================
--- gobject/pygtype.c	(revision 1053)
+++ gobject/pygtype.c	(working copy)
@@ -716,11 +716,6 @@
 	break;
     case G_TYPE_INT:
 	g_value_set_int(value, _PyLong_AsLong(obj));
-	if (PyErr_Occurred()) {
-	    g_value_unset(value);
-	    PyErr_Clear();
-	    return -1;
-	}
 	break;
     case G_TYPE_UINT:
 	{
@@ -734,21 +729,11 @@
 		    return -1;
 	    } else {
 		g_value_set_uint(value, PyLong_AsUnsignedLong(obj));
-		if (PyErr_Occurred()) {
-		    g_value_unset(value);
-		    PyErr_Clear();
-		    return -1;
-		}
 	    }
 	}
 	break;
     case G_TYPE_LONG:
 	g_value_set_long(value, _PyLong_AsLong(obj));
-	if (PyErr_Occurred()) {
-	    g_value_unset(value);
-	    PyErr_Clear();
-	    return -1;
-	}
 	break;
     case G_TYPE_ULONG:
 	{
@@ -762,26 +747,19 @@
 		    return -1;
 	    } else {
 		g_value_set_ulong(value, PyLong_AsUnsignedLong(obj));
-		if (PyErr_Occurred()) {
-		    g_value_unset(value);
-		    PyErr_Clear();
-		    return -1;
-		}
 	    }
 	}
 	break;
     case G_TYPE_INT64:
 	g_value_set_int64(value, PyLong_AsLongLong(obj));
-	if (PyErr_Occurred()) {
-	    g_value_unset(value);
-	    PyErr_Clear();
-	    return -1;
-	}
 	break;
     case G_TYPE_UINT64:
-        if (_PyLong_Check(obj))
-            g_value_set_uint64(value, _PyLong_AsLong(obj));
-        else if (PyLong_Check(obj))
+#if PY_VERSION_HEX < 0x03000000
+        if (PyInt_Check(obj))
+            g_value_set_uint64(value, PyInt_AsLong(obj));
+        else
+#endif
+        if (PyLong_Check(obj))
             g_value_set_uint64(value, PyLong_AsUnsignedLongLong(obj));
         else
             return -1;
@@ -808,19 +786,9 @@
 	break;
     case G_TYPE_FLOAT:
 	g_value_set_float(value, PyFloat_AsDouble(obj));
-	if (PyErr_Occurred()) {
-	    g_value_unset(value);
-	    PyErr_Clear();
-	    return -1;
-	}
 	break;
     case G_TYPE_DOUBLE:
 	g_value_set_double(value, PyFloat_AsDouble(obj));
-	if (PyErr_Occurred()) {
-	    g_value_unset(value);
-	    PyErr_Clear();
-	    return -1;
-	}
 	break;
     case G_TYPE_STRING:
 	if (obj == Py_None)
@@ -915,6 +883,11 @@
 	    break;
 	}
     }
+    if (PyErr_Occurred()) {
+        g_value_unset(value);
+        PyErr_Clear();
+        return -1;
+    }
     return 0;
 }
 
