According to the Python (2.7) documentation:
Due to the precarious circumstances under which __del__() methods are
invoked, exceptions that occur during their execution are ignored, and
a warning is printed to sys.stderr instead
What would be the most Pythonic way to completely and absolutely ignore an exception raised in __del__() — that is, not only having the exception ignored but also nothing printed to sterr. Is there a better way than temporarily redirecting stderr to the null device?
I am assuming this is in a
__del__()function that you are writing, if so, just catch the exception yourself and ignore it.The logging to stderr only applies for uncaught exceptions in
__del__().