wok diff pygtk/stuff/python27.patch @ rev 16380

ARM: try to fix glib cross compile
author Christophe Lincoln <pankso@slitaz.org>
date Tue Apr 15 03:48:06 2014 +0200 (2014-04-15)
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/pygtk/stuff/python27.patch	Tue Apr 15 03:48:06 2014 +0200
     1.3 @@ -0,0 +1,50 @@
     1.4 +diff --git a/gtk/gtkmodule.c b/gtk/gtkmodule.c
     1.5 +index c0e1493..aa8cf10 100644
     1.6 +--- a/gtk/gtkmodule.c
     1.7 ++++ b/gtk/gtkmodule.c
     1.8 +@@ -227,8 +227,12 @@ init_gtk(void)
     1.9 +     pygtk_add_stock_items(d);
    1.10 +     
    1.11 +     /* extension API */
    1.12 +-    PyDict_SetItemString(d, "_PyGtk_API",
    1.13 +-			 o=PyCObject_FromVoidPtr(&functions, NULL));
    1.14 ++#if PY_VERSION_HEX >= 0x02070000
    1.15 ++    o = PyCapsule_New(&functions, "gtk._gtk._PyGtk_API", NULL);
    1.16 ++#else
    1.17 ++    o = PyCObject_FromVoidPtr(&functions, NULL);
    1.18 ++#endif
    1.19 ++    PyDict_SetItemString(d, "_PyGtk_API", o);
    1.20 +     Py_DECREF(o);
    1.21 + 	
    1.22 +     PyGtkDeprecationWarning = PyErr_NewException("gtk.GtkDeprecationWarning",
    1.23 +diff --git a/gtk/pygtk.h b/gtk/pygtk.h
    1.24 +index 573c3b9..e4c680f 100644
    1.25 +--- a/gtk/pygtk.h
    1.26 ++++ b/gtk/pygtk.h
    1.27 +@@ -60,6 +60,18 @@ struct _PyGtk_FunctionStruct *_PyGtk_API;
    1.28 + 
    1.29 + 
    1.30 + /* a function to initialise the pygtk functions */
    1.31 ++
    1.32 ++/* Python 2.7 introduced the PyCapsule API and deprecated the CObject API */
    1.33 ++#if PY_VERSION_HEX >= 0x02070000
    1.34 ++#define init_pygtk() G_STMT_START { \
    1.35 ++    void *capsule = PyCapsule_Import("gtk._gtk._PyGtk_API", 0); \
    1.36 ++    if (!capsule) { \
    1.37 ++        return; \
    1.38 ++    } \
    1.39 ++    _PyGtk_API = (struct _PyGtk_FunctionStruct*)capsule; \
    1.40 ++} G_STMT_END
    1.41 ++#else /* PY_VERSION_HEX */
    1.42 ++/* Python 2.6 and earlier use the CObject API */
    1.43 + #define init_pygtk() G_STMT_START { \
    1.44 +     PyObject *pygtk = PyImport_ImportModule("gtk"); \
    1.45 +     if (pygtk != NULL) { \
    1.46 +@@ -79,6 +91,7 @@ struct _PyGtk_FunctionStruct *_PyGtk_API;
    1.47 +         return; \
    1.48 +     } \
    1.49 + } G_STMT_END
    1.50 ++#endif /* PY_VERSION_HEX */
    1.51 + 
    1.52 + #endif
    1.53 +