Should I always call PyErr_Clear() when an exception occurs?

Fredrik Lundh fredrik at pythonware.com
Tue Dec 21 12:53:09 EST 2004


Jaime Wyant wrote:

> What exactly "happens" if I leave the exception hanging out there?

the user of your code will most likely get spurious exceptions raised in
odd locations (many python operations assume that the exception state
is cleared when you call them, and check the status afterwards)

it's bloody annoying, and can take hours or days to track down, so it's
worth fixing.

</F> 






More information about the Python-list mailing list