Re: Python 2.7 deprecated the PyCObject API?

James William Pye <lists@jwp.name>

From: James William Pye <lists@jwp.name>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers@postgresql.org
Date: 2010-08-14T02:16:27Z
Lists: pgsql-hackers
On Aug 13, 2010, at 5:20 PM, Tom Lane wrote:
> According to a discussion over in Fedora-land, $subject is true:
> http://lists.fedoraproject.org/pipermail/devel/2010-August/140995.html
> 
> I see several calls in plpython.c that seem to refer to PyCObject stuff.
> Anybody have any idea if we need to do something about this?


Well, we should at least be checking for an exception here anyways:

        proc->me = PyCObject_FromVoidPtr(proc, NULL);
        PyDict_SetItemString(PLy_procedure_cache, key, proc->me);

if (proc->me == NULL) complain();

That is, with those warnings adjustments, proc->me will be NULL and then explode in PyDict_SetItemString:

[David Malcolm]
However, if someone overrides the process-wide warnings settings, then
the API can fail altogether, raising a PendingDeprecationWarning
exception (which in CPython terms means setting a thread-specific error
state and returning NULL).
./


AFA a better fix is concerned, the shortest route would seem to be to use the new capsule stuff iff Python >= 2.7.