wok view pygtk/stuff/python27.patch @ rev 9195

busybox: add conspy fix
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Mar 09 22:01:54 2011 +0100 (2011-03-09)
parents
children
line source
1 diff --git a/gtk/gtkmodule.c b/gtk/gtkmodule.c
2 index c0e1493..aa8cf10 100644
3 --- a/gtk/gtkmodule.c
4 +++ b/gtk/gtkmodule.c
5 @@ -227,8 +227,12 @@ init_gtk(void)
6 pygtk_add_stock_items(d);
8 /* extension API */
9 - PyDict_SetItemString(d, "_PyGtk_API",
10 - o=PyCObject_FromVoidPtr(&functions, NULL));
11 +#if PY_VERSION_HEX >= 0x02070000
12 + o = PyCapsule_New(&functions, "gtk._gtk._PyGtk_API", NULL);
13 +#else
14 + o = PyCObject_FromVoidPtr(&functions, NULL);
15 +#endif
16 + PyDict_SetItemString(d, "_PyGtk_API", o);
17 Py_DECREF(o);
19 PyGtkDeprecationWarning = PyErr_NewException("gtk.GtkDeprecationWarning",
20 diff --git a/gtk/pygtk.h b/gtk/pygtk.h
21 index 573c3b9..e4c680f 100644
22 --- a/gtk/pygtk.h
23 +++ b/gtk/pygtk.h
24 @@ -60,6 +60,18 @@ struct _PyGtk_FunctionStruct *_PyGtk_API;
27 /* a function to initialise the pygtk functions */
28 +
29 +/* Python 2.7 introduced the PyCapsule API and deprecated the CObject API */
30 +#if PY_VERSION_HEX >= 0x02070000
31 +#define init_pygtk() G_STMT_START { \
32 + void *capsule = PyCapsule_Import("gtk._gtk._PyGtk_API", 0); \
33 + if (!capsule) { \
34 + return; \
35 + } \
36 + _PyGtk_API = (struct _PyGtk_FunctionStruct*)capsule; \
37 +} G_STMT_END
38 +#else /* PY_VERSION_HEX */
39 +/* Python 2.6 and earlier use the CObject API */
40 #define init_pygtk() G_STMT_START { \
41 PyObject *pygtk = PyImport_ImportModule("gtk"); \
42 if (pygtk != NULL) { \
43 @@ -79,6 +91,7 @@ struct _PyGtk_FunctionStruct *_PyGtk_API;
44 return; \
45 } \
46 } G_STMT_END
47 +#endif /* PY_VERSION_HEX */
49 #endif