]> git.pld-linux.org Git - packages/python-pygtk.git/blame - python-pygtk-python27.patch
fix shebangs
[packages/python-pygtk.git] / python-pygtk-python27.patch
CommitLineData
a83390c6
ER
1diff --git a/gtk/gtkmodule.c b/gtk/gtkmodule.c
2index 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);
7
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);
18
19 PyGtkDeprecationWarning = PyErr_NewException("gtk.GtkDeprecationWarning",
20diff --git a/gtk/pygtk.h b/gtk/pygtk.h
21index 573c3b9..e4c680f 100644
22--- a/gtk/pygtk.h
23+++ b/gtk/pygtk.h
24@@ -60,6 +60,18 @@ struct _PyGtk_FunctionStruct *_PyGtk_API;
25
26
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 */
48
49 #endif
50
This page took 0.075983 seconds and 4 git commands to generate.