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

Bug in pretty printing #2122

Closed
doerwalter opened this issue Jul 11, 2012 · 1 comment · Fixed by #2123
Closed

Bug in pretty printing #2122

doerwalter opened this issue Jul 11, 2012 · 1 comment · Fixed by #2123
Milestone

Comments

@doerwalter
Copy link
Contributor

The code in IPython.lib.pretty.RepresentationPrinter.pretty has a bug: it fails to look in the class __dict__s of the classes in the MRO. Fixes this is pretty easy:

--- pretty.py.orig  2012-07-11 15:38:34.000000000 +0200
+++ pretty.py   2012-07-11 15:32:05.000000000 +0200
@@ -354,7 +354,7 @@
                         # Some objects automatically create any requested
                         # attribute. Try to ignore most of them by checking for
                         # callability.
-                        if '_repr_pretty_' in obj_class.__dict__:
+                        if '_repr_pretty_' in cls.__dict__:
                             meth = obj_class._repr_pretty_
                             if isinstance(meth, collections.Callable):
                                 return meth(obj, self, cycle)
@juliantaylor
Copy link
Contributor

is it possible to add a somewhat more meaningful testcase for this?
Its not really clear to my why the behavior tested for in the testcase is the desired behavior compared to the pre fix situation.
Getting Dummy1() as representation for Dummy2 violates the rule (convention?) that representation should be unambigous.

@minrk minrk added this to the 1.0 milestone Mar 26, 2014
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014
…ather than the original leaf class.

Thanks, @doerwalter for finding this and suggesting the fix.

fixes ipython#2122
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants