Index: gst/pygstvalue.c
===================================================================
RCS file: /cvs/gstreamer/gst-python/gst/pygstvalue.c,v
retrieving revision 1.5
diff -u -r1.5 pygstvalue.c
--- gst/pygstvalue.c	22 Nov 2005 14:15:03 -0000	1.5
+++ gst/pygstvalue.c	1 Dec 2006 12:01:05 -0000
@@ -33,6 +33,24 @@
 static PyObject *gstfraction_class = NULL;
 static PyObject *gstfractionrange_class = NULL;
 
+/* helper function */
+
+/* Finds the greatest common divisor.
+ * Returns 1 if none other found.
+ * This is Euclid's algorithm. */
+static long
+my_gcd(long num, long denom)
+{
+  while (denom != 0) {
+    long temp = num;
+
+    num = denom;
+    denom = temp % denom;
+  }
+
+  return ABS (num);
+}
+
 /**
  * pygst_value_as_pyobject:
  * @value: the GValue object.
@@ -221,14 +239,26 @@
     } else if (PyObject_IsInstance (obj, gstfraction_class)) {
       PyObject *pyval;
       long num, denom;
+      long gcd = 0;
       VALUE_TYPE_CHECK (value, GST_TYPE_FRACTION);
       if (!(pyval = PyObject_GetAttrString (obj, "num")))
         return -1;
       num = PyInt_AsLong (pyval);
+      if ((num == -1) && PyErr_Occurred())
+	return -1;
       g_assert (G_MININT <= num && num <= G_MAXINT);
       if (!(pyval = PyObject_GetAttrString (obj, "denom")))
         return -1;
       denom = PyInt_AsLong (pyval);
+      if ((denom == -1) && PyErr_Occurred())
+	return -1;
+      GST_DEBUG ("num:%ld , denom:%ld", num, denom);
+      /* we need to reduce the values to be smaller than MAXINT */
+      if ((gcd = my_gcd(num, denom))) {
+	num /= gcd;
+	denom /= gcd;
+	GST_DEBUG ("gcd:%ld , num:%ld, denom:%ld", gcd, num, denom);
+      }
       g_assert (G_MININT <= denom && denom <= G_MAXINT);
       gst_value_set_fraction (value, (int)num, (int)denom);
     } else if (PyObject_IsInstance (obj, gstfractionrange_class)) {
