Anonymous avatar Anonymous committed 4724054

Reenabled Python 2.4 default builds, the demand is there. Fixed dumb compiler optimisation issues for Python2.4 builds.

Comments (0)

Files changed (6)

 # purposes only!
 
 buildall: clean
+	@python2.4 setup.py build
 	@python2.5 setup.py build
 	@python2.6 setup.py build
 	@python3.1 setup.py build
 
 installall:
+	@python2.4 setup.py install
 	@python2.5 setup.py install
 	@python2.6 setup.py install
 	@python3.1 setup.py install
 
 testall:
+	@python2.4 test/run_tests.py
 	@python2.5 test/run_tests.py
 	@python2.6 test/run_tests.py
 	@python3.1 test/run_tests.py
 
 testall2:
+	@python2.4 -c "import pygame2.test; pygame2.test.run ()"
 	@python2.5 -c "import pygame2.test; pygame2.test.run ()"
 	@python2.6 -c "import pygame2.test; pygame2.test.run ()"
 	@python3.1 -c "import pygame2.test; pygame2.test.run ()"
 
 purge_installs:
+	rm -rf /usr/local/include/python2.4/pygame2*
 	rm -rf /usr/local/include/python2.5/pygame2*
 	rm -rf /usr/local/include/python2.6/pygame2*
 	rm -rf /usr/local/include/python3.1/pygame2*
+	rm -rf /usr/local/lib/python2.4/site-packages/pygame2*
 	rm -rf /usr/local/lib/python2.5/site-packages/pygame2*
 	rm -rf /usr/local/lib/python2.6/site-packages/pygame2*
 	rm -rf /usr/local/lib/python3.1/site-packages/pygame2*

src/freetype/ft_font.c

     error = PGFT_GetTextSize(ft, font, &render, text, &width, &height);
     
     if (error)
-        PyErr_SetString(PyExc_RuntimeError, PGFT_GetError(ft));
+    {
+        if (!PyErr_Occurred ())
+            PyErr_SetString(PyExc_RuntimeError, PGFT_GetError(ft));
+    }
     else
         rtuple = Py_BuildValue ("(ii)", width, height);
 

src/freetype/ft_text.c

     }
 
     /* get the text as an unicode string */
-    orig_buffer = buffer = PGFT_BuildUnicodeString(text);
+    orig_buffer = buffer = PGFT_BuildUnicodeString(ft, text);
 
     if (!buffer)
-    {
-        _PGFT_SetError(ft, "Invalid text string specified", 0);
         return NULL;
-    }
-
+    
     /* get the length of the text */
     for (ch = buffer; *ch; ++ch)
     {
 }
 
 FT_UInt16 *
-PGFT_BuildUnicodeString(PyObject *obj)
+PGFT_BuildUnicodeString(FreeTypeInstance *ft, PyObject *obj)
 {
-    size_t len;
+    Py_ssize_t len;
     FT_UInt16 *utf16_buffer = NULL;
     char *tmp_buffer;
 
         if (!utf_bytes)
             return NULL;
 
-        if (Bytes_AsStringAndSize(utf_bytes, &tmp_buffer, (int *)&len) == -1)
+        if (Bytes_AsStringAndSize
+            (utf_bytes, &tmp_buffer, &len) == -1)
         {
             Py_DECREF (utf_bytes);
             return NULL;
         }
 
-        utf16_buffer = malloc(len + 2);
+        utf16_buffer = malloc((size_t)len + 2);
         if (!utf16_buffer)
         {
             Py_DECREF (utf_bytes);
+            _PGFT_SetError(ft, "Could not allocate memory", 0);
             return NULL;
         }
-        memcpy(utf16_buffer, tmp_buffer, len);
+        memcpy(utf16_buffer, tmp_buffer, (size_t) len);
         utf16_buffer[len / sizeof(FT_UInt16)] = 0;
 
         Py_DECREF(utf_bytes);
          * UTF8 anyway?), so manually copy the raw contents
          * of the object expanding each byte to 16 bits.
          */
-        size_t i;
+        Py_ssize_t i;
 
-        if (Bytes_AsStringAndSize(obj, &tmp_buffer, (int *)&len) == -1)
+        if (Bytes_AsStringAndSize(obj, &tmp_buffer, &len) == -1)
             return NULL;
 
-        utf16_buffer = malloc((len + 1) * sizeof(FT_UInt16));
+        utf16_buffer = malloc(((size_t)len + 1) * sizeof(FT_UInt16));
         if (!utf16_buffer)
+        {
+            _PGFT_SetError(ft, "Could not allocate memory", 0);
             return NULL;
+        }
 
         for (i = 0; i < len; ++i)
-            utf16_buffer[i] = (FT_UInt16)tmp_buffer[i];
+        {
+            utf16_buffer[i] = (FT_UInt16)(tmp_buffer[i]);
+        }
         utf16_buffer[len] = 0;
     }
 

src/freetype/ft_wrap.h

 int         PGFT_LoadTextAdvances(FreeTypeInstance *ft, PyFreeTypeFont *font, 
                 const FontRenderMode *render, FontText *text);
 
-FT_UInt16 * PGFT_BuildUnicodeString(PyObject *);
+FT_UInt16 * PGFT_BuildUnicodeString(FreeTypeInstance *ft, PyObject *text);
 
 
 /******************************************************** Glyph cache management ****/
 static PyObject*
 _sdl_wasinit (PyObject *self, PyObject *args)
 {
-    Uint32 flags = SDL_INIT_EVERYTHING, retval;
+    Uint32 flags = SDL_INIT_EVERYTHING, retval = 0;
 
     if (!PyArg_ParseTuple (args, "|l:was_init", &flags))
         return NULL;
+    Py_BEGIN_ALLOW_THREADS;
     retval = SDL_WasInit (flags);
+    Py_END_ALLOW_THREADS;
     return PyLong_FromLong ((long)retval);
 }
 

test/sdl_video_pixelformat_test.py

         
         def _setr (format, readonly):
             format.readonly = readonly
-        
-        self.assertRaises (AttributeError, _setr, format, True)
-        self.assertRaises (AttributeError, _setr, format, False)
+
+        if sys.version_info < (2, 5):
+            self.assertRaises (TypeError, _setr, format, True)
+            self.assertRaises (TypeError, _setr, format, False)
+        else:
+            self.assertRaises (AttributeError, _setr, format, True)
+            self.assertRaises (AttributeError, _setr, format, False)
         
         video.quit ()
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.