Some C-API functions clear the error indicator?
duncan.booth at invalid.invalid
Fri Jan 29 15:58:42 CET 2010
Austin Bingham <austin.bingham at gmail.com> wrote:
> The functions that do this don't seem to indicate in their
> documentation that this will happen. So first, does anyone know why
> this is happening? Is it because of the context in which I'm making
> the calls? Is there any pattern or reason behind which functions will
> do this? Or am I just doing something wrong?
(Just guessing here)
I would expect that any function that executes Python code will clear the
I think that has to happen otherwise the Python code will throw an
exception whenever it gets round to checking for errors. In the past I've
found that if you fail to check for an error in C code before returning to
the interpreter you get the exception thrown a few instructions later, so
something similar would probably happen if you call other Python code from
If it is anything that executes Python then that would include any function
that creates or destroys an object with Python constructor or destructor
code. or that compares or otherwise operates on instances defined in
Python. In particular it might mean that any function that doesn't appear
to clear the error could do so in a slightly different situation.
Duncan Booth http://kupuguy.blogspot.com
More information about the Python-list