[pygobject] Revert "add compat functions for the deprecated PyCObject api"
- From: John Palmieri <johnp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] Revert "add compat functions for the deprecated PyCObject api"
- Date: Mon, 4 Oct 2010 16:52:14 +0000 (UTC)
commit 1e1357f5fa1a034b0b707040d664ac46be6e23f7
Author: John (J5) Palmieri <johnp redhat com>
Date: Mon Oct 4 12:50:55 2010 -0400
Revert "add compat functions for the deprecated PyCObject api"
This reverts commit f25e763d53e5cdd4de08e90b04aea4b4c4720ac0.
I ment to commit another patch and ended up comitting both
gi/gimodule.c | 2 +-
gi/pygi.h | 5 +----
glib/glibmodule.c | 2 +-
glib/pyglib-python-compat.h | 19 -------------------
glib/pyglib.c | 6 +++---
glib/pygoptioncontext.c | 2 +-
gobject/gobjectmodule.c | 2 +-
gobject/pygobject.h | 6 ------
gobject/pygtype.c | 10 +++++-----
9 files changed, 13 insertions(+), 41 deletions(-)
---
diff --git a/gi/gimodule.c b/gi/gimodule.c
index d42e7e4..89caf4e 100644
--- a/gi/gimodule.c
+++ b/gi/gimodule.c
@@ -328,7 +328,7 @@ PYGLIB_MODULE_START(_gi, "_gi")
_pygi_boxed_register_types (module);
_pygi_argument_init();
- api = PYGLIB_PyCapsule_New ( (void *) &CAPI, "gi._API");
+ api = PyCObject_FromVoidPtr ( (void *) &CAPI, NULL);
if (api == NULL) {
return;
}
diff --git a/gi/pygi.h b/gi/pygi.h
index da71d28..c5a0f26 100644
--- a/gi/pygi.h
+++ b/gi/pygi.h
@@ -83,11 +83,8 @@ _pygi_import (void)
if (PyGI_API != NULL) {
return 1;
}
-#if PY_VERSION_HEX >= 0x02070000
- PyGI_API = (struct PyGI_API*) PyCapsule_Import("gi._API", FALSE);
-#else
+
PyGI_API = (struct PyGI_API*) PyCObject_Import("gi", "_API");
-#endif
if (PyGI_API == NULL) {
return -1;
}
diff --git a/glib/glibmodule.c b/glib/glibmodule.c
index f1c8168..4a58bc2 100644
--- a/glib/glibmodule.c
+++ b/glib/glibmodule.c
@@ -797,7 +797,7 @@ pyglib_register_api(PyObject *d)
/* for addon libraries ... */
PyDict_SetItemString(d, "_PyGLib_API",
- o=PYGLIB_PyCapsule_New(&pyglib_api,"glib._PyGLib_API"));
+ o=PyCObject_FromVoidPtr(&pyglib_api,NULL));
Py_DECREF(o);
pyglib_init_internal(o);
diff --git a/glib/pyglib-python-compat.h b/glib/pyglib-python-compat.h
index 222fc8c..bb7bcad 100644
--- a/glib/pyglib-python-compat.h
+++ b/glib/pyglib-python-compat.h
@@ -41,25 +41,6 @@ typedef int Py_ssize_t;
typedef inquiry lenfunc;
#endif
-/* PyCObject superceded by PyCapsule on Python >= 2.7 */
-#if PY_VERSION_HEX >= 0x02070000
-# define PYGLIB_PyCapsule_Check PyCapsule_CheckExact
-# define PYGLIB_PyCapsule_New(ptr, typename) \
- PyCapsule_New(ptr, typename, NULL)
-# define PYGLIB_PyCapsule_GetPointer(obj, typename) \
- PyCapsule_GetPointer(obj, typename)
-# define PYGLIB_PyCapsule_Import(module, symbol) \
- PyCapsule_Import(##module##.##symbol##, FALSE)
-#else
-# define PYGLIB_PyCapsule_Check PyCObject_Check
-# define PYGLIB_PyCapsule_New(ptr, typename) \
- PyCObject_FromVoidPtr(ptr, NULL)
-# define PYGLIB_PyCapsule_GetPointer(obj, typename) \
- PyCObject_AsVoidPtr(obj)
-# define PYGLIB_PyCapsule_Import(module, symbol) \
- PyCObject_Import(module, symbol)
-#endif
-
#if PY_VERSION_HEX < 0x03000000
#define PYGLIB_INIT_FUNCTION(modname, fullpkgname, functions) \
diff --git a/glib/pyglib.c b/glib/pyglib.c
index 7e1b106..07db579 100644
--- a/glib/pyglib.c
+++ b/glib/pyglib.c
@@ -71,8 +71,8 @@ pyglib_init(void)
}
cobject = PyObject_GetAttrString(glib, "_PyGLib_API");
- if (cobject && PYGLIB_PyCapsule_Check(cobject))
- _PyGLib_API = (struct _PyGLib_Functions *) PYGLIB_PyCapsule_GetPointer(cobject, "glib._PyGLib_API");
+ if (cobject && PyCObject_Check(cobject))
+ _PyGLib_API = (struct _PyGLib_Functions *) PyCObject_AsVoidPtr(cobject);
else {
PyErr_SetString(PyExc_ImportError,
"could not import glib (could not find _PyGLib_API object)");
@@ -88,7 +88,7 @@ pyglib_init(void)
void
pyglib_init_internal(PyObject *api)
{
- _PyGLib_API = (struct _PyGLib_Functions *) PYGLIB_PyCapsule_GetPointer(api, "glib._PyGLib_API");
+ _PyGLib_API = (struct _PyGLib_Functions *) PyCObject_AsVoidPtr(api);
}
gboolean
diff --git a/glib/pygoptioncontext.c b/glib/pygoptioncontext.c
index fe0a2b3..1d67ac5 100644
--- a/glib/pygoptioncontext.c
+++ b/glib/pygoptioncontext.c
@@ -288,7 +288,7 @@ pyg_option_context_richcompare(PyObject *self, PyObject *other, int op)
static PyObject *
pyg_option_get_context(PyGOptionContext *self)
{
- return PYGLIB_PyCapsule_New(self->context, "goption.context");
+ return PyCObject_FromVoidPtr(self->context, NULL);
}
static PyMethodDef pyg_option_context_methods[] = {
diff --git a/gobject/gobjectmodule.c b/gobject/gobjectmodule.c
index b6d6f1d..4e9c07d 100644
--- a/gobject/gobjectmodule.c
+++ b/gobject/gobjectmodule.c
@@ -2511,7 +2511,7 @@ pygobject_register_api(PyObject *d)
{
PyObject *api;
- api = PYGLIB_PyCapsule_New(&pygobject_api_functions, "gobject._PyGObject_API");
+ api = PyCObject_FromVoidPtr(&pygobject_api_functions,NULL);
PyDict_SetItemString(d, "_PyGObject_API", api);
Py_DECREF(api);
}
diff --git a/gobject/pygobject.h b/gobject/pygobject.h
index c803634..e75c890 100644
--- a/gobject/pygobject.h
+++ b/gobject/pygobject.h
@@ -352,14 +352,8 @@ pygobject_init(int req_major, int req_minor, int req_micro)
}
cobject = PyObject_GetAttrString(gobject, "_PyGObject_API");
-#if PY_VERSION_HEX >= 0x02070000
- if (cobject && PyCapsule_CheckExact(cobject))
- _PyGObject_API = (struct _PyGObject_Functions *) PyCapsule_GetPointer(cobject, "gobject._PyGObject_API");
-
-#else
if (cobject && PyCObject_Check(cobject))
_PyGObject_API = (struct _PyGObject_Functions *) PyCObject_AsVoidPtr(cobject);
-#endif
else {
PyErr_SetString(PyExc_ImportError,
"could not import gobject (could not find _PyGObject_API object)");
diff --git a/gobject/pygtype.c b/gobject/pygtype.c
index 19d8b64..c875aa2 100644
--- a/gobject/pygtype.c
+++ b/gobject/pygtype.c
@@ -864,8 +864,8 @@ pyg_value_from_pyobject(GValue *value, PyObject *obj)
else if (PyObject_TypeCheck(obj, &PyGPointer_Type) &&
G_VALUE_HOLDS(value, ((PyGPointer *)obj)->gtype))
g_value_set_pointer(value, pyg_pointer_get(obj, gpointer));
- else if (PYGLIB_PyCapsule_Check(obj))
- g_value_set_pointer(value, PYGLIB_PyCapsule_GetPointer(obj, NULL));
+ else if (PyCObject_Check(obj))
+ g_value_set_pointer(value, PyCObject_AsVoidPtr(obj));
else
return -1;
break;
@@ -910,15 +910,15 @@ pyg_value_from_pyobject(GValue *value, PyObject *obj)
}
else if ((bm = pyg_type_lookup(G_VALUE_TYPE(value))) != NULL)
return bm->tovalue(value, obj);
- else if (PYGLIB_PyCapsule_Check(obj))
- g_value_set_boxed(value, PYGLIB_PyCapsule_GetPointer(obj, NULL));
+ else if (PyCObject_Check(obj))
+ g_value_set_boxed(value, PyCObject_AsVoidPtr(obj));
else
return -1;
break;
}
case G_TYPE_PARAM:
if (PyGParamSpec_Check(obj))
- g_value_set_param(value, PYGLIB_PyCapsule_GetPointer(obj, NULL));
+ g_value_set_param(value, PyCObject_AsVoidPtr(obj));
else
return -1;
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]