[Python-checkins] r72397 - python/branches/py3k/Objects/cobject.c

georg.brandl python-checkins at python.org
Wed May 6 10:47:57 CEST 2009


Author: georg.brandl
Date: Wed May  6 10:47:56 2009
New Revision: 72397

Log:
#5947: add PendingDeprecationWarning to PyCObject functions.

Modified:
   python/branches/py3k/Objects/cobject.c

Modified: python/branches/py3k/Objects/cobject.c
==============================================================================
--- python/branches/py3k/Objects/cobject.c	(original)
+++ python/branches/py3k/Objects/cobject.c	Wed May  6 10:47:56 2009
@@ -9,11 +9,23 @@
 typedef void (*destructor1)(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 *
 PyCObject_FromVoidPtr(void *cobj, void (*destr)(void *))
 {
     PyCObject *self;
 
+    if (deprecation_exception()) {
+        return NULL;
+    }
+
     self = PyObject_NEW(PyCObject, &PyCObject_Type);
     if (self == NULL)
         return NULL;
@@ -30,6 +42,10 @@
 {
     PyCObject *self;
 
+    if (deprecation_exception()) {
+        return NULL;
+    }
+
     if (!desc) {
         PyErr_SetString(PyExc_TypeError,
                         "PyCObject_FromVoidPtrAndDesc called with null"


More information about the Python-checkins mailing list