Commits

tanoku  committed 0bf9f8d

Fixed module initialization error in several SDL modules under Pygame 3.0
Added global 'IS_PYTHON_3' define to setup.py so all headers are built with the define if needed.

  • Participants
  • Parent commits 2b5d4d3
  • Branches pgreloaded

Comments (0)

Files changed (5)

     if buildsystem == "darwin":
         os.environ["CFLAGS"] += " -arch i386 -arch ppc"
 
+    if helpers.getversion() >= (3, 0):
+        os.environ["CFLAGS"] += " -DIS_PYTHON_3"
+
     packages = [ "pygame2",
                  "pygame2.examples",
                  "pygame2.examples.physics",

File src/pgcompat.h

 
 /* Python 3.x compatibility */
 #if PY_VERSION_HEX >= 0x03000000
-#define IS_PYTHON_3
+
+#ifndef IS_PYTHON_3
+#   define IS_PYTHON_3
+#endif
 
 /* Define some aliases for the removed PyInt_* functions */
 #define PyInt_Check(op) PyLong_Check(op)

File src/sdl/cdrommod.c

 _cdrom_clear (PyObject *mod)
 {
     int i;
-    _SDLCDromState *state = SDLCDROM_MOD_STATE(self);
+    _SDLCDromState *state = SDLCDROM_MOD_STATE(mod);
     for (i = 0; i < MAX_CDROMS; i++)
     {
         /* Close all open cdroms. */

File src/sdl/eventmod.c

 }
 
 #ifdef IS_PYTHON_3
-struct PyModuleDef _module = {
+struct PyModuleDef _eventmodule = {
     PyModuleDef_HEAD_INIT,
     "event",
     DOC_EVENT,
-    -1,
+    sizeof(_SDLEventState),
     _event_methods,
     NULL,
     _event_traverse,
     Py_INCREF (&PyEvent_Type);
 
 #ifdef IS_PYTHON_3
-    mod = PyModule_Create (&_module);
+    mod = PyModule_Create (&_eventmodule);
 #else
     mod = Py_InitModule3 ("event", _event_methods, DOC_EVENT);
 #endif

File src/sdl/eventmod.h

 #include <Python.h>
 #include <SDL.h>
 
-/*
- * HACK: The 'IS_PYTHON_3' define is somehow
- * not declared when compiling this module.
- * We need to manually include pgcompat.h
- */
-#include "pgcompat.h"
-
 #define PYGAME_SDLEVENT_INTERNAL
 
 typedef struct {