-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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
resolve python2 str() issue #4030
Conversation
superset/viz.py
Outdated
@@ -1300,9 +1300,9 @@ def get_data(self, df): | |||
for i, v in ys.iteritems(): | |||
x = i | |||
if isinstance(x, (tuple, list)): | |||
x = ', '.join([str(s) for s in x]) | |||
x = ', '.join([str(s.encode('utf8')) for s in x]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you want to use six.text_type(s)
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
time to upgrade to py3!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@john-bodley I tried six.text_type but it didn't work. python 2 str uses ascii encoding scheme by default so it will break unless utf-8 is specified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@john-bodley I removed the str(). six.text_type makes sense now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may also need to add the utf-8 encoding header at the top
# -*- coding: utf-8 -*-
@xrmx I think that's for when there are non-ascii characters in the python file and that's not the case here. |
LGTM |
* make string conversion use utf8 * Update viz.py * make utf-8 consistent with other usages * Update viz.py * Update viz.py
* make string conversion use utf8 * Update viz.py * make utf-8 consistent with other usages * Update viz.py * Update viz.py
Some slices with utf8 characters are breaking during the string conversion in the lines changed. This removes the str and uses six.text_type so it stays unicode in python2 and becomes str in python3.
@john-bodley @mistercrunch