Roundup Robot added the comment:
New changeset ddd7db7cf036 by Victor Stinner in branch '3.4':
Issue #21497: faulthandler functions now raise a better error if sys.stderr is
http://hg.python.org/cpython/rev/ddd7db7cf036
New changeset cb26887f9140 by Victor Stinner in branch 'default':
(Merge
STINNER Victor added the comment:
I applied my patch, thanks for the report.
--
resolution: - fixed
status: open - closed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21497
___
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:
STINNER Victor added the comment:
Attached patch modifies faulthandler to raises a RuntimeError(sys.stderr is
None) with your use case. Is it what you expected?
--
keywords: +patch
Added file: http://bugs.python.org/file35243/faulthandler.patch
___
Florian Bruhin added the comment:
I didn't test the patch (I don't have the toolchain set up to do so), but it
looks like this is indeed an exception which makes more sense to the developer.
When I saw the exception as it is now, I only discovered it's related to stderr
being None by finding
STINNER Victor added the comment:
I personally would prefer failing silently though so the application still
runs (if there's no stderr, there just is no fault log), but that's debatable
of course.
Nope, there is no debate: there is the Zen of Python :-)
Errors should never pass silently.
Florian Bruhin added the comment:
The thing is the developer is not necessarely the one controlling if sys.stderr
is None, sometimes the user is.
For example, see
https://docs.python.org/3.4/using/windows.html#executing-scripts-without-the-python-launcher
- an user might have decided to use
STINNER Victor added the comment:
This means there's an unexpected gotcha
I prefer to see an exception before sys.stderr is None, instead of not seeing
the traceback when the application does crash. It is usually a pain to
reproduce a crash in the exact same conditions.
if I want my