Python 3 traceback fails when no exception is active
我注意到在Python2中,当我尝试转储异常堆栈跟踪,但没有活动异常时,它会打印
1 2 3 4 | Python 2.7.2+ (default, Oct 4 2011, 20:06:09) >>> import traceback >>> traceback.print_exc() None |
但Python3失败了一些内部问题:
1 2 3 4 5 6 7 8 9 10 11 12 | Python 3.2.2 (default, Sep 5 2011, 21:17:14) >>> import traceback >>> traceback.print_exc() Traceback (most recent call last): File"<stdin>", line 1, in <module> File"/usr/lib/python3.2/traceback.py", line 259, in print_exc print_exception(etype, value, tb, limit, file, chain) File"/usr/lib/python3.2/traceback.py", line 155, in print_exception for value, tb in values: File"/usr/lib/python3.2/traceback.py", line 122, in _iter_chain cause = exc.__cause__ AttributeError: 'NoneType' object has no attribute '__cause__' |
这是Python中的错误,还是我应该在调用
那是一个错误。 可能会决定应该引发错误,但这肯定是错误的错误。