Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
kcarnold opened this issue Nov 30, 2011 · 1 comment
Labels
Milestone

Comments

@kcarnold
Copy link

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/pretty.py b/IPython/lib/pretty.py
index 4361f21..f6f109c 100644
--- a/IPython/lib/pretty.py
+++ b/IPython/lib/pretty.py
@@ -668,7 +668,7 @@ _type_pprinters = {

 try:
     _type_pprinters[types.DictProxyType] = _dict_pprinter_factory('<dictproxy {', '}>')
-    _type_pprinters[types.ClassType] = _type_pprint,
+    _type_pprinters[types.ClassType] = _type_pprint
 except AttributeError: # Python 3
     pass
@minrk minrk closed this as completed in 13c8185 Nov 30, 2011
@minrk
Copy link
Member

minrk commented Nov 30, 2011

thanks, fix pushed.

mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants