Commits

illume  committed 1ccfd2b

Fixed some failing tests for Color and LONG_MAX on 64bit python.

  • Participants
  • Parent commits b55888c

Comments (0)

Files changed (1)

 static PyObject*
 _color_int (PyColor *color)
 {
-    unsigned long tmp = (color->r << 24) + (color->g << 16) + (color->b << 8) +
-        color->a;
+    Uint32 tmp = (color->r << 24) + (color->g << 16) + 
+                 (color->b << 8) + color->a;
 #if !PY3
-    if (tmp < INT_MAX)
+    if (tmp < LONG_MAX)
         return PyInt_FromLong ((long) tmp);
 #endif
     return PyLong_FromUnsignedLong (tmp);
 static PyObject*
 _color_long (PyColor *color)
 {
-    unsigned long tmp = (color->r << 24) + (color->g << 16) + (color->b << 8) +
+    Uint32 tmp = (color->r << 24) + (color->g << 16) + (color->b << 8) +
         color->a;
     return PyLong_FromUnsignedLong (tmp);
 }
 static PyObject*
 _color_float (PyColor *color)
 {
-    unsigned long tmp = (color->r << 24) + (color->g << 16) + (color->b << 8) +
+    Uint32 tmp = (color->r << 24) + (color->g << 16) + (color->b << 8) +
         color->a;
     return PyFloat_FromDouble ((double) tmp);
 }
 _color_oct (PyColor *color)
 {
     char buf[100];
-    unsigned long tmp = (color->r << 24) + (color->g << 16) + (color->b << 8) +
+    Uint32 tmp = (color->r << 24) + (color->g << 16) + (color->b << 8) +
         color->a;
-    if (tmp < INT_MAX)
-        PyOS_snprintf (buf, sizeof (buf), "0%lo", tmp);
+
+    if (tmp < LONG_MAX)
+        PyOS_snprintf (buf, sizeof (buf), "0%lo", (unsigned long) tmp);
     else
-        PyOS_snprintf (buf, sizeof (buf), "0%loL", tmp);
+        PyOS_snprintf (buf, sizeof (buf), "0%loL", (unsigned long) tmp);
     return PyString_FromString (buf);
 }
 
 _color_hex (PyColor *color)
 {
     char buf[100];
-    unsigned long tmp = (color->r << 24) + (color->g << 16) + (color->b << 8) +
+    Uint32 tmp = (color->r << 24) + (color->g << 16) + (color->b << 8) +
         color->a;
-    if (tmp < INT_MAX)
-        PyOS_snprintf (buf, sizeof (buf), "0x%lx", tmp);
+    if (tmp < LONG_MAX)
+        PyOS_snprintf (buf, sizeof (buf), "0x%lx", (unsigned long) tmp);
     else
     {
 #if PY_VERSION_HEX >= 0x02050000
-        PyOS_snprintf (buf, sizeof (buf), "0x%lxL", tmp);
+        PyOS_snprintf (buf, sizeof (buf), "0x%lxL", (unsigned long) tmp);
 #else
         /* <= 2.4 uses capitalised hex chars. */
-        PyOS_snprintf (buf, sizeof (buf), "0x%lXL", tmp);
+        PyOS_snprintf (buf, sizeof (buf), "0x%lXL", (unsigned long) tmp);
 #endif
     }
     return Text_FromUTF8 (buf);