Skip to content

Commit 0e669f6

Browse files
committed
Fix unhashable exception types
1 parent bdc17e4 commit 0e669f6

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/werkzeug/debug/tbtools.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,11 @@ def __init__(self, exc_type, exc_value, tb):
248248
memo = set()
249249
while True:
250250
self.groups.append(Group(exc_type, exc_value, tb))
251-
memo.add(exc_value)
251+
memo.add(id(exc_value))
252252
if PY2:
253253
break
254254
exc_value = exc_value.__cause__ or exc_value.__context__
255-
if exc_value is None or exc_value in memo:
255+
if exc_value is None or id(exc_value) in memo:
256256
break
257257
exc_type = type(exc_value)
258258
tb = exc_value.__traceback__

tests/test_debug.py

+11
Original file line numberDiff line numberDiff line change
@@ -371,3 +371,14 @@ def test_chained_exception_cycle():
371371
# if cycles aren't broken, this will time out
372372
tb = Traceback(TypeError, error, error.__traceback__)
373373
assert len(tb.groups) == 2
374+
375+
376+
def test_non_hashable_exception():
377+
class MutableException(ValueError):
378+
__hash__ = None
379+
380+
try:
381+
raise MutableException()
382+
except MutableException:
383+
# previously crashed: `TypeError: unhashable type 'MutableException'`
384+
Traceback(*sys.exc_info())

0 commit comments

Comments
 (0)