Message218461
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 |
|
Date |
User |
Action |
Args |
2014-05-13 14:09:29 | The Compiler | set | recipients:
+ The Compiler, vstinner |
2014-05-13 14:09:29 | The Compiler | set | messageid: <1399990169.45.0.873283104693.issue21497@psf.upfronthosting.co.za> |
2014-05-13 14:09:29 | The Compiler | link | issue21497 messages |
2014-05-13 14:09:29 | The Compiler | create | |
|