Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unhashable exception types #1542

Merged
merged 1 commit into from May 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/werkzeug/debug/tbtools.py
Expand Up @@ -248,11 +248,11 @@ def __init__(self, exc_type, exc_value, tb):
memo = set()
while True:
self.groups.append(Group(exc_type, exc_value, tb))
memo.add(exc_value)
memo.add(id(exc_value))
if PY2:
break
exc_value = exc_value.__cause__ or exc_value.__context__
if exc_value is None or exc_value in memo:
if exc_value is None or id(exc_value) in memo:
break
exc_type = type(exc_value)
tb = exc_value.__traceback__
Expand Down
11 changes: 11 additions & 0 deletions tests/test_debug.py
Expand Up @@ -371,3 +371,14 @@ def test_chained_exception_cycle():
# if cycles aren't broken, this will time out
tb = Traceback(TypeError, error, error.__traceback__)
assert len(tb.groups) == 2


def test_non_hashable_exception():
class MutableException(ValueError):
__hash__ = None

try:
raise MutableException()
except MutableException:
# previously crashed: `TypeError: unhashable type 'MutableException'`
Traceback(*sys.exc_info())