Message381938
TracebackException holds a reference to the exc_traceback, which is wrong because (1) it's supposed to capture the output without holding references to real things. (2) it makes comparison wrong for equivalent exceptions, as in this example:
------------------------------------------
import sys
import traceback
excs = []
for _ in range(2):
try:
1/0
except:
excs.append(traceback.TracebackException(*sys.exc_info()))
print('formats equal: ', list(excs[0].format()) == list(excs[0].format()))
print('excs equal: ', excs[0] == excs[1])
excs[0].exc_traceback = excs[1].exc_traceback = None
print('excs equal w/o exc_traceback: ', excs[0] == excs[1])
------------------------------------------
Output:
formats equal: True
excs equal: False
excs equal w/o exc_traceback: True
------------------------------------------
The good news is that it's only used to check for non-None (added here https://bugs.python.org/issue24695) so should be easy to remove. |
|
Date |
User |
Action |
Args |
2020-11-27 10:11:08 | iritkatriel | set | recipients:
+ iritkatriel |
2020-11-27 10:11:08 | iritkatriel | set | messageid: <1606471868.96.0.673168968518.issue42482@roundup.psfhosted.org> |
2020-11-27 10:11:08 | iritkatriel | link | issue42482 messages |
2020-11-27 10:11:08 | iritkatriel | create | |
|