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

Already on GitHub? Sign in to your account

Fix pretty printing dispatch #1535

Merged
merged 2 commits into from Apr 15, 2012

Conversation

Projects
None yet
3 participants
Contributor

doerwalter commented Mar 30, 2012

This patch fixes a problem mentioned here:

http://mail.scipy.org/pipermail/ipython-dev/2012-March/008874.html

Search for the best method to use for pretty printing an object now no longer prefers any registered printer in type_printers for the class or any of the base classes over a _repr_pretty_ method defined in the class or any of its base classes.

Instead the mro is walked, looking for both registered printers and _repr_pretty_ methods, so that the inheritance hierarchy will be taken into account.

doerwalter added some commits Mar 30, 2012

Fix dispatching in the pretty printing module.
Search for the best method to use for pretty printing an object
now no longer prefers any registered printer in type_printers for
the class or any of the base classes over a _repr_pretty_ method
defined in the class or any of its base classes.

Instead the mro is walked, looking for both registered printers
and _repr_pretty_ methods, so that the inheritance hierarchy will
be taken into account.
Don't use getattr() when searching for the _repr_pretty_ method.
Using getattr() might find a method in a base class, when a registered
printer for a baseclass later in the mro is the better fit.
Owner

minrk commented Apr 10, 2012

Looks pretty sound to me. If anyone with more experience here wants to have a peek, please do.

Owner

fperez commented Apr 15, 2012

Great, thanks @doerwalter for this fix! Sorry it took us a while to review, March and early April were insane for most of the core devs.

Code is clean, with tests; merging now.

fperez added a commit that referenced this pull request Apr 15, 2012

Merge pull request #1535 from doerwalter/master
Fix pretty printing dispatch.

This patch fixes a problem mentioned here: http://mail.scipy.org/pipermail/ipython-dev/2012-March/008874.html

Search for the best method to use for pretty printing an object now no longer prefers any registered printer in `type_printers` for the class or any of the base classes over a `_repr_pretty_` method defined in the class or any of its base classes.

Instead the mro is walked, looking for both registered printers and `_repr_pretty_` methods, so that the inheritance hierarchy will be taken into account.

@fperez fperez merged commit 81039be into ipython:master Apr 15, 2012

mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014

Merge pull request #1535 from doerwalter/master
Fix pretty printing dispatch.

This patch fixes a problem mentioned here: http://mail.scipy.org/pipermail/ipython-dev/2012-March/008874.html

Search for the best method to use for pretty printing an object now no longer prefers any registered printer in `type_printers` for the class or any of the base classes over a `_repr_pretty_` method defined in the class or any of its base classes.

Instead the mro is walked, looking for both registered printers and `_repr_pretty_` methods, so that the inheritance hierarchy will be taken into account.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment