New submission from Arfrever Frehtes Taifersar Arahesis:
Usage of some functions from traceback module can result in AttributeError
exception in Python 3, while simply printing/returning something with None in
Python 2.
This regression was introduced in Python 3.0.
$ python2.7 -c 'import traceback; print(traceback.print_exc())'
None
None
$ python2.7 -c 'import traceback; print(traceback.print_exception(None, None,
None))'
None
None
$ python2.7 -c 'import traceback; print(traceback.format_exc())'
None
$ python2.7 -c 'import traceback; print(traceback.format_exception(None, None,
None))'
['None\n']
$ python3.5 -c 'import traceback; print(traceback.print_exc())'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib64/python3.5/traceback.py", line 252, in print_exc
print_exception(*sys.exc_info(), limit=limit, file=file, chain=chain)
File "/usr/lib64/python3.5/traceback.py", line 169, in print_exception
for line in _format_exception_iter(etype, value, tb, limit, chain):
File "/usr/lib64/python3.5/traceback.py", line 146, in _format_exception_iter
for value, tb in values:
File "/usr/lib64/python3.5/traceback.py", line 125, in _iter_chain
context = exc.__context__
AttributeError: 'NoneType' object has no attribute '__context__'
$ python3.5 -c 'import traceback; print(traceback.print_exception(None, None,
None))'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib64/python3.5/traceback.py", line 169, in print_exception
for line in _format_exception_iter(etype, value, tb, limit, chain):
File "/usr/lib64/python3.5/traceback.py", line 146, in _format_exception_iter
for value, tb in values:
File "/usr/lib64/python3.5/traceback.py", line 125, in _iter_chain
context = exc.__context__
AttributeError: 'NoneType' object has no attribute '__context__'
$ python3.5 -c 'import traceback; print(traceback.format_exc())'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib64/python3.5/traceback.py", line 256, in format_exc
return "".join(format_exception(*sys.exc_info(), limit=limit, chain=chain))
File "/usr/lib64/python3.5/traceback.py", line 181, in format_exception
return list(_format_exception_iter(etype, value, tb, limit, chain))
File "/usr/lib64/python3.5/traceback.py", line 146, in _format_exception_iter
for value, tb in values:
File "/usr/lib64/python3.5/traceback.py", line 125, in _iter_chain
context = exc.__context__
AttributeError: 'NoneType' object has no attribute '__context__'
$ python3.5 -c 'import traceback; print(traceback.format_exception(None, None,
None))'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib64/python3.5/traceback.py", line 181, in format_exception
return list(_format_exception_iter(etype, value, tb, limit, chain))
File "/usr/lib64/python3.5/traceback.py", line 146, in _format_exception_iter
for value, tb in values:
File "/usr/lib64/python3.5/traceback.py", line 125, in _iter_chain
context = exc.__context__
AttributeError: 'NoneType' object has no attribute '__context__'
----------
messages: 232259
nosy: Arfrever
priority: normal
severity: normal
status: open
title: traceback.{print_exc,print_exception,format_exc,format_exception}:
Potential AttributeError
versions: Python 3.4, Python 3.5
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue23003>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com