This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author The Compiler
Recipients The Compiler, vstinner
Date 2014-05-13.14:09:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1399990169.45.0.873283104693.issue21497@psf.upfronthosting.co.za>
In-reply-to
Content
When faulthandler is used while sys.stderr is None (e.g. when using pythonw.exe), a (IMHO) confusing exception is raised:

    Traceback (most recent call last):
      File "test.py", line 7, in <module>
         faulthandler.enable()
    AttributeError: 'NoneType' object has no attribute 'fileno'

Example script which demonstrates the issue without using pythonw.exe:

    import faulthandler
    import sys

    sys.stderr = None

    try:
        faulthandler.enable()
    except:
        sys.stderr = sys.__stderr__
        raise

Looking at the code it seems the file passed gets correctly checked against NULL and Py_None, but stderr (as fallback) then only gets checked against NULL:

http://hg.python.org/cpython/file/8885fc2e92b3/Modules/faulthandler.c#l141
History
Date User Action Args
2014-05-13 14:09:29The Compilersetrecipients: + The Compiler, vstinner
2014-05-13 14:09:29The Compilersetmessageid: <1399990169.45.0.873283104693.issue21497@psf.upfronthosting.co.za>
2014-05-13 14:09:29The Compilerlinkissue21497 messages
2014-05-13 14:09:29The Compilercreate