That makes a lot of sense. And if I take the approach that any Py* function might do this, it actually looks like I can simplify my code (rather than managing some list of ill-behaved functions or something.) Thanks!
On Fri, Jan 29, 2010 at 3:58 PM, Duncan Booth <duncan.bo...@invalid.invalid> wrote: > Austin Bingham <austin.bing...@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 > error. > > 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 > C. > > 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 > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list