[New-bugs-announce] [issue23016] uncatched exception in lib/warnings.py when executed with pythonw
stockbsd Li
report at bugs.python.org
Tue Dec 9 02:27:03 CET 2014
New submission from stockbsd Li:
in py3k, the following simple code will throw an uncatched exception when executed with pythonw:
import warnings
warnings.warn('test')
the problem occurs in showarning function: in py3k's pythonw , stderr/stdout is set to None, so the file.write(...) statement will thorw AttributeError uncatched. I think a catch-all except(delete 'OSError') can solve this.
def showwarning(message, category, filename, lineno, file=None, line=None):
"""Hook to write a warning to a file; replace if you like."""
if file is None:
file = sys.stderr
try:
file.write(formatwarning(message, category, filename, lineno, line))
except OSError:
pass # the file (probably stderr) is invalid - this warning gets lost.
----------
components: Library (Lib)
messages: 232342
nosy: stockbsd
priority: normal
severity: normal
status: open
title: uncatched exception in lib/warnings.py when executed with pythonw
type: crash
versions: Python 3.2, Python 3.3, Python 3.4
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23016>
_______________________________________
More information about the New-bugs-announce
mailing list