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

fix printing of unicode attributes #892

Closed
wants to merge 1 commit into from

Conversation

rabernat
Copy link
Contributor

fixes #834

I would welcome a suggestion of how to test this in a way that works with both python 2 and 3. This is somewhat outside my expertise.

def _str_or_unicode(obj):
"""A drop in replacement for str() which properly handles unicode.
"""
if isinstance(obj, unicode_type):
Copy link
Member

Choose a reason for hiding this comment

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

I think we actually want to handle this the other way around: convert everything to unicode (str on Python 3). Maybe something like:

if isinstance(obj, bytes):
    obj = obj.decode('ascii')
return unicode_type(obj)

@shoyer
Copy link
Member

shoyer commented Jul 21, 2016

I just put up an alternative (with tests) in #914.

@shoyer
Copy link
Member

shoyer commented Jul 24, 2016

Fixed by #914

@shoyer shoyer closed this Jul 24, 2016
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.

open_dataset error, "UnicodeEncodeError: 'ascii' codec can't encode character u'\ufffd' .."
2 participants