Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6142c8e

Browse files
committed
Consistent pretty(a_class) on bogus qualname/name
+1 test passing in PyPy
1 parent b6a880d commit 6142c8e

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

IPython/lib/pretty.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -670,8 +670,10 @@ def _type_pprint(obj, p, cycle):
670670
# Heap allocated types might not have the module attribute,
671671
# and others may set it to None.
672672

673-
# Checks for a __repr__ override in the metaclass
674-
if type(obj).__repr__ is not type.__repr__:
673+
# Checks for a __repr__ override in the metaclass. Can't compare the
674+
# type(obj).__repr__ directly because in PyPy the representation function
675+
# inherited from type isn't the same type.__repr__
676+
if [m for m in _get_mro(type(obj)) if "__repr__" in vars(m)][:1] != [type]:
675677
_repr_pprint(obj, p, cycle)
676678
return
677679

0 commit comments

Comments
 (0)