This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Arfrever
Recipients Arfrever
Date 2014-12-06.23:37:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1417909047.64.0.652633919593.issue23003@psf.upfronthosting.co.za>
In-reply-to
Content
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__'
History
Date User Action Args
2014-12-06 23:37:27Arfreversetrecipients: + Arfrever
2014-12-06 23:37:27Arfreversetmessageid: <1417909047.64.0.652633919593.issue23003@psf.upfronthosting.co.za>
2014-12-06 23:37:27Arfreverlinkissue23003 messages
2014-12-06 23:37:27Arfrevercreate