Skip to content

BUG: Fix pretty-printing for overzealous objects #1495

merged 1 commit into from Mar 16, 2012

2 participants

rkern commented Mar 15, 2012

Some classes use __getattr__ to automatically create requested attributes. The recent trend of LINQ-like query objects is what I ran into. This confuses the pretty-printing machinery that tests for _repr_pretty_. This pull request fixes many of these problems by simply testing if the _repr_pretty_ attribute is callable. This may still be confused by certain mocking frameworks, but it's a good start.

@rkern rkern BUG: Fix pretty-printing for overzealous objects that will return som…
…ething non-callable for any requested attribute (thus confusing hasattr).
IPython member
minrk commented Mar 15, 2012

Looks clean and sensible to me. Can you name a few libraries that do this sort of thing? Perhaps Pyro, etc. Maybe we can run some extra tests if some of these libraries are present.

rkern commented Mar 15, 2012 is the one I was using when I ran into the problem.

IPython member
minrk commented Mar 16, 2012

We've also had completion issues with these libraries. It would be useful to give a few tests so that future changes will be caught. But for now, I think this can just be merged, unless you want to write a simple test with underverse now.

rkern commented Mar 16, 2012

I added a test with a badly-formed _repr_pretty_ attribute. I could write one with a __getattr__ that returns a generator for greater verisimilitude, but I'm not sure what else that would catch that the current test doesn't.

@minrk minrk merged commit 873e364 into ipython:master Mar 16, 2012
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.