Commit 5cc7933c authored by Georg Brandl's avatar Georg Brandl

#5947: add PendingDeprecationWarning to PyCObject functions.

parent 60dc7c17
...@@ -9,11 +9,23 @@ ...@@ -9,11 +9,23 @@
typedef void (*destructor1)(void *); typedef void (*destructor1)(void *);
typedef void (*destructor2)(void *, void*); typedef void (*destructor2)(void *, void*);
static int deprecation_exception(void)
{
return PyErr_WarnEx(PyExc_PendingDeprecationWarning,
"The CObject API is deprecated as of Python 3.1. "
"Please convert to using the Capsule API.", 1);
}
PyObject * PyObject *
PyCObject_FromVoidPtr(void *cobj, void (*destr)(void *)) PyCObject_FromVoidPtr(void *cobj, void (*destr)(void *))
{ {
PyCObject *self; PyCObject *self;
if (deprecation_exception()) {
return NULL;
}
self = PyObject_NEW(PyCObject, &PyCObject_Type); self = PyObject_NEW(PyCObject, &PyCObject_Type);
if (self == NULL) if (self == NULL)
return NULL; return NULL;
...@@ -30,6 +42,10 @@ PyCObject_FromVoidPtrAndDesc(void *cobj, void *desc, ...@@ -30,6 +42,10 @@ PyCObject_FromVoidPtrAndDesc(void *cobj, void *desc,
{ {
PyCObject *self; PyCObject *self;
if (deprecation_exception()) {
return NULL;
}
if (!desc) { if (!desc) {
PyErr_SetString(PyExc_TypeError, PyErr_SetString(PyExc_TypeError,
"PyCObject_FromVoidPtrAndDesc called with null" "PyCObject_FromVoidPtrAndDesc called with null"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment