Skip to content

Fix pretty print of types when __module__ is not available. #2685

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

Merged
merged 2 commits into from
Dec 16, 2012

Conversation

bfroehle
Copy link
Contributor

In Python 3, heap allocated types -- for example those created using
PyType_FromSpec -- lack the __module__ attribute.

Closes #2684

In Python 3, heap allocated types -- for example those created using
PyType_FromSpec -- lack the `__module__` attribute.

Closes ipython#2684
mod = obj.__module__
except AttributeError:
# Heap allocated types might not have the module attribute.
return p.text(obj.__name__)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no way __name__ could be missing too, I hope?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I went and read the C source -- name will always be defined.

@takluyver
Copy link
Member

Great, looks good to me, then. Could we also add a simple tests? It can be conditional on xxlimited being importable, assuming that's widely available (I've got it on my Python 3 installations).

@bfroehle
Copy link
Contributor Author

Okay, added a test. I think it was skipped on Travis py32 test, but it runs for me locally.

@takluyver
Copy link
Member

Great, thanks. I'll land this, then.

takluyver added a commit that referenced this pull request Dec 16, 2012
Fix pretty print of types when `__module__` is not available.
@takluyver takluyver merged commit bb2d35b into ipython:master Dec 16, 2012
minrk added a commit that referenced this pull request Mar 5, 2013
… available.

In Python 3, heap allocated types -- for example those created using
PyType_FromSpec -- lack the `__module__` attribute.

Closes #2684
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
Fix pretty print of types when `__module__` is not available.
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 this pull request may close these issues.

pretty print broken for types created with PyType_FromSpec
2 participants