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

Allow reading HTML tables with unicode values #5410

Merged
merged 2 commits into from
Oct 21, 2016

Conversation

taldcroft
Copy link
Member

Fixes #5409.

Test reading a table with unicode values
"""
# If we don't have unicode literals then return
if isinstance('', bytes):
Copy link
Contributor

Choose a reason for hiding this comment

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

To avoid this and using TEST_UNICODE_LITERALS, the strings below could simply be defined with the u'...' syntax, or maybe I miss something ?

@taldcroft
Copy link
Member Author

@saimn - good point. During development I did try using unicode strings at one point and this failed, but this might have been when there were other problems. I tried just and it worked as expected, so this is definitely cleaner. New rebased version pushed.

@mhvk
Copy link
Contributor

mhvk commented Oct 16, 2016

Should this be a bug fix?

Also, I noticed this overrides default_converters from TableOutputter -- just in case: would it make sense to just change the default there? Or do other things go wrong then?

@taldcroft taldcroft self-assigned this Oct 19, 2016
@taldcroft
Copy link
Member Author

@mhvk - reading unicode in Python 2.7 is not supported per the following Note in the docs:

Reading a table which contains non-ASCII (unicode) characters is only supported in Python 3 or
greater. If you have Python 2.x and need this functionality, consider using a newer version of
Python.

So this is really not a bug because reading unicode is explicitly not supported. But of course we could be more liberal about the definition of a bug.

@taldcroft taldcroft removed their assignment Oct 19, 2016
@taldcroft
Copy link
Member Author

And as a reminder, unicode is not supported for Python 2.7 because all the other Python readers use the stdlib csv module for splitting text, and this does not support unicode without shenanigans. This falls in the category of "we're not going to spend effort making this work on Python 2 when you should instead migrate to Python 3."

@mhvk
Copy link
Contributor

mhvk commented Oct 19, 2016

@taldcroft - OK, makes sense. I agree that we should not put effort in making this work on python2

@taldcroft taldcroft merged commit 2c6000a into astropy:master Oct 21, 2016
@taldcroft taldcroft deleted the ascii-html-unicode branch October 21, 2016 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants