Skip to content

pprinting old-style class objects fails (TypeError: 'tuple' object is not callable) #1074

kcarnold opened this Issue Nov 30, 2011 · 1 comment

2 participants

In [1]: class A: pass
In [2]: A
/Users/kcarnold/.virtualenvs/py27/lib/python2.7/site-packages/IPython/lib/pretty.pyc in pretty(self, obj)
    341             for cls in _get_mro(obj_class):
    342                 if cls in self.type_pprinters:
--> 343                     return self.type_pprinters[cls](obj, self, cycle)
    344                 else:
    345                     printer = self._in_deferred_types(cls)

TypeError: 'tuple' object is not callable

Unfortunately some classes in the Python standard library are old-style, so I stumbled across this one.

The fix is trivial and hardly worth a pull request:

diff --git a/IPython/lib/ b/IPython/lib/
index 4361f21..f6f109c 100644
--- a/IPython/lib/
+++ b/IPython/lib/
@@ -668,7 +668,7 @@ _type_pprinters = {

     _type_pprinters[types.DictProxyType] = _dict_pprinter_factory('<dictproxy {', '}>')
-    _type_pprinters[types.ClassType] = _type_pprint,
+    _type_pprinters[types.ClassType] = _type_pprint
 except AttributeError: # Python 3
@minrk minrk closed this in 13c8185 Nov 30, 2011
IPython member
minrk commented Nov 30, 2011

thanks, fix pushed.

@mattvonrocketstein mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014
@minrk minrk remove erroneous trailing comma in lib.pretty
c/o @kcarnold
closes #1074
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.