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

Catch failure in repr() for %whos #1729

Merged
merged 2 commits into from May 12, 2012
Merged

Conversation

takluyver
Copy link
Member

As recently reported on the mailing list, an object whose repr() fails catches out %whos. This catches the error and uses a fallback representation.

@@ -953,6 +953,8 @@ def type_name(v):
except UnicodeEncodeError:
vstr = unicode(var).encode(DEFAULT_ENCODING,
'backslashreplace')
except:
vstr = "<object with id %d (str() failed)>" % id(var)
Copy link
Member

Choose a reason for hiding this comment

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

Should this say str() or repr() instead? Since depending on what an object actually implements, the error could come from either, it might be a bit more informative...

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, it's str() that actually failed, even if that called the object's __repr__ method. I'm conscious that the line length is limited, and I think it's sufficient information for someone who wants to fix it.

Copy link
Member

Choose a reason for hiding this comment

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

Fair enough; merging now. Thanks!

fperez added a commit that referenced this pull request May 12, 2012
Catch failure in repr() for %whos
@fperez fperez merged commit 8408171 into ipython:master May 12, 2012
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
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.

None yet

2 participants