[Python-3000] PyException_Set{Traceback,Cause,Context}

Guido van Rossum guido at python.org
Mon Jun 23 02:32:41 CEST 2008


On Sun, Jun 22, 2008 at 1:25 PM, Antoine Pitrou <solipsis at pitrou.net> wrote:
> I don't know who designed that API but what is the reason for
> PyException_Set{Traceback,Cause,Context} not to INCREF their argument? It means
> the caller has to do it himself, and seems inconsistent with most of Python's C
> API. Is it too late to change those functions to do the right thing?

I'm guessing Collin Winter designed it when he implemented the first
half of PEP 3134. (There is no mention of these APIs in the PEP.)
Looking at the source code it looks like all the cases so far where
these are actually used, this API is actually fortunate -- in all
cases I've found the ownership for the argument needs to be passed
into the exception object anyway.

There are some precedents, e.g. PyList_SetItem().

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list