[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>
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
----------
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>
<http://bugs.python.org/issue21497>
_______________________________________
More information about the Python-bugs-list
mailing list