[New-bugs-announce] [issue27348] Non-main thread exception handler drops exception message

Martin Panter report at bugs.python.org
Sat Jun 18 10:57:36 EDT 2016


New submission from Martin Panter:

If the exception argument is None or repr(None), it is omitted from the report when a thread raises an unhandled exception:

>>> def raise_exception(e):
...     raise e
... 
>>> t = Thread(target=raise_exception, args=(Exception(None),)); t.start(); t.join()
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/home/proj/python/cpython/Lib/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/home/proj/python/cpython/Lib/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "<stdin>", line 2, in raise_exception
Exception

>>> t = Thread(target=raise_exception, args=(Exception("None"),)); t.start(); t.join()
Exception in thread Thread-2:
Traceback (most recent call last):
  File "/home/proj/python/cpython/Lib/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/home/proj/python/cpython/Lib/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "<stdin>", line 2, in raise_exception
Exception

Compare the result with other exception messages, the normal sys.excepthook() report, and Python 2:

>>> t = Thread(target=raise_exception, args=(Exception("NONE"),)); t.start(); t.join()
Exception in thread Thread-3:
Traceback (most recent call last):
  File "/home/proj/python/cpython/Lib/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/home/proj/python/cpython/Lib/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "<stdin>", line 2, in raise_exception
Exception: NONE

>>> raise Exception(None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
Exception: None

----------
messages: 268814
nosy: martin.panter
priority: normal
severity: normal
status: open
title: Non-main thread exception handler drops exception message
versions: Python 3.5, Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27348>
_______________________________________


More information about the New-bugs-announce mailing list