[issue24696] Don't use None as sentinel for traceback
Adam Bartoš
report at bugs.python.org
Thu Jul 23 16:52:20 CEST 2015
New submission from Adam Bartoš:
There is a subtle bug in Python 3.4 implementation of traceback library:
>>> import traceback
>>>
>>> try:
... 1 / 0
... except Exception as e:
... exc = e
...
>>> traceback.print_exception(exc.__class__, exc, exc.__traceback__)
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
ZeroDivisionError: division by zero
>>>
>>> traceback.print_exception(exc.__class__, exc, None)
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
ZeroDivisionError: division by zero
>>>
>>> traceback.print_exception(exc.__class__, exc, None, chain=False)
ZeroDivisionError: division by zero
As can be seen, giving None traceback is ignored if chain == True. This is because None is incorrectly used as a sentinel value in traceback._iter_chain (see line 135).
Note that this bug is fixed in Python 3.5 since there is a new implementation of traceback module using TracebackException objects. Will this be backported to Python 3.4? Otherwise, the bug itself should be fixed anyway.
----------
components: Library (Lib)
messages: 247210
nosy: Drekin
priority: normal
severity: normal
status: open
title: Don't use None as sentinel for traceback
type: behavior
versions: Python 3.4
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24696>
_______________________________________
More information about the Python-bugs-list
mailing list