Navigation Menu

Skip to content

Commit

Permalink
Check whether output from obj.safely_stringify_for_pudb() is actually…
Browse files Browse the repository at this point in the history
… a string, so as to not be confused by Mock objects (closes #270 on github)
  • Loading branch information
inducer committed Sep 2, 2017
1 parent fb9f256 commit fe46357
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pudb/var_view.py
Expand Up @@ -234,9 +234,14 @@ def type_stringifier(value):

elif hasattr(value, "safely_stringify_for_pudb"):
try:
return value.safely_stringify_for_pudb()
# (E.g.) Mock objects will pretend to have this
# and return nonsense.
result = value.safely_stringify_for_pudb()
except Exception:
pass
else:
if isinstance(result, string_types):
return result

return type(value).__name__

Expand Down

0 comments on commit fe46357

Please sign in to comment.