[New-bugs-announce] [issue21497] faulthandler should handle sys.stderr being None gracefully

Florian Bruhin report at bugs.python.org
Tue May 13 16:09:29 CEST 2014

New submission from Florian Bruhin:

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>
    AttributeError: 'NoneType' object has no attribute 'fileno'

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

    import faulthandler
    import sys

    sys.stderr = None

        sys.stderr = sys.__stderr__

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:


components: Extension Modules
messages: 218461
nosy: The Compiler, haypo
priority: normal
severity: normal
status: open
title: faulthandler should handle sys.stderr being None gracefully
type: behavior
versions: Python 3.3, Python 3.4

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list