[Python-Dev] Integrate the faulthandler module into Python 3.3?

Antoine Pitrou solipsis at pitrou.net
Fri Mar 4 13:54:25 CET 2011


On Fri, 04 Mar 2011 13:40:16 +0100
Victor Stinner <victor.stinner at haypocalc.com> wrote:
> > I am still bothered by the fact that,
> > 
> > >>> import faulthandler
> > >>> faulthandler.enable()
> > >>> import sys
> > >>> sys.stderr.close()
> > >>> sys.stderr = open('logs/error.log', 'wb')
> > >>> faulthandler.sigsegv()
> > 
> > , does the wrong thing.
> 
> faulthandler.enable() uses sys.stderr by default: it keeps a reference
> on this object and stores its descriptor (should be 2). If you close the
> file descriptor (eg. sys.stderr.close())

sys.stderr.close() doesn't close the file descriptor under Python 3:

>>> import sys, os
>>> sys.stderr.close()
>>> os.write(2, b"foo\n")
foo
4

Regards

Antoine.




More information about the Python-Dev mailing list