On Aug 14, 2010, at 9:08 AM, Tom Lane wrote:
> Just to clarify, you're recommending something like
> 
>               proc->me = PyCObject_FromVoidPtr(proc, NULL);
> +             if (proc->me == NULL)
> +                     elog(ERROR, "could not create PyCObject for function");
>               PyDict_SetItemString(PLy_procedure_cache, key, proc->me);
> 
> correct?  (Hm, and it looks like we'd better move the pfree just above 
> that...)

Almost, there's still a Python exception to report and/or clear.
I only glanced at this and didn't recall what the plpython mechanisms were for 
that, thus the ambiguous "complain()".

> Yeah, and since we'll have to back-patch it, a fairly noninvasive patch
> would be nice.  Will you work on that?

I was hoping that Peter would pop in with a patch, but I think a few lines of 
CPP may suffice..
(warning: untested =)

#ifdef Py_CAPSULE_H
/*
 * Python.h (2.7 and up) includes pycapsule.h, so rely on the header
 * define to detect the API's existence.
 */
#define PyCObject_FromVoidPtr(POINTER, IGNORED) PyCapsule_New(POINTER, NULL, 
NULL)
#undef PyCObject_Check
#define PyCObject_Check(OBJ) PyCapsule_CheckExact(OBJ)
#define PyCObject_AsVoidPtr(OBJ) PyCapsule_GetPointer(OBJ, NULL)
#endif /* Py_CAPSULE_H */

http://svn.python.org/view/python/branches/release27-maint/Include/pycapsule.h?view=markup

yay? nay?
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to