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