summaryrefslogtreecommitdiffstats
path: root/contrib/python/ipython/py3/IPython/lib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/python/ipython/py3/IPython/lib')
-rw-r--r--contrib/python/ipython/py3/IPython/lib/pretty.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/contrib/python/ipython/py3/IPython/lib/pretty.py b/contrib/python/ipython/py3/IPython/lib/pretty.py
index 631445b24e3..8a24632d600 100644
--- a/contrib/python/ipython/py3/IPython/lib/pretty.py
+++ b/contrib/python/ipython/py3/IPython/lib/pretty.py
@@ -406,8 +406,16 @@ class RepresentationPrinter(PrettyPrinter):
meth = cls._repr_pretty_
if callable(meth):
return meth(obj, self, cycle)
- if cls is not object \
- and callable(cls.__dict__.get('__repr__')):
+ if (
+ cls is not object
+ # check if cls defines __repr__
+ and "__repr__" in cls.__dict__
+ # check if __repr__ is callable.
+ # Note: we need to test getattr(cls, '__repr__')
+ # instead of cls.__dict__['__repr__']
+ # in order to work with descriptors like partialmethod,
+ and callable(_safe_getattr(cls, "__repr__", None))
+ ):
return _repr_pprint(obj, self, cycle)
return _default_pprint(obj, self, cycle)