Merge pull request #4632 from AnjoMan/dont-rewrite-objects-with-failing-getattr
Assertion rewrite breaks for objects that reimplement `__getattr__`
This commit is contained in:
@@ -525,7 +525,13 @@ def _format_assertmsg(obj):
|
||||
|
||||
|
||||
def _should_repr_global_name(obj):
|
||||
return not hasattr(obj, "__name__") and not callable(obj)
|
||||
if callable(obj):
|
||||
return False
|
||||
|
||||
try:
|
||||
return not hasattr(obj, "__name__")
|
||||
except Exception:
|
||||
return True
|
||||
|
||||
|
||||
def _format_boolop(explanations, is_or):
|
||||
|
||||
Reference in New Issue
Block a user