Skip to content

unicode() --> six.u() for Python 3 compatibility#111

Merged
dbieber merged 1 commit into
google:masterfrom
cclauss:patch-1
Jan 11, 2018
Merged

unicode() --> six.u() for Python 3 compatibility#111
dbieber merged 1 commit into
google:masterfrom
cclauss:patch-1

Conversation

@cclauss

@cclauss cclauss commented Jan 11, 2018

Copy link
Copy Markdown
Contributor

unicode() was removed from Python 3 because all strs are unicode.

Executing these lines in Python 3 would raise a NameError.

__unicode()__ was removed from Python 3 because all strs are unicode.

Executing these lines in Python 3 would raise a NameError.

* https://pythonhosted.org/six/#six.u
@dbieber

dbieber commented Jan 11, 2018

Copy link
Copy Markdown
Collaborator

lgtm!, thanks

@dbieber dbieber merged commit 9bff9d0 into google:master Jan 11, 2018
@cclauss cclauss deleted the patch-1 branch January 11, 2018 00:22
@djizm

djizm commented Jan 12, 2018 via email

Copy link
Copy Markdown

@dbieber

dbieber commented Jun 21, 2018

Copy link
Copy Markdown
Collaborator

Turns out six.u does not behave the same as unicode in Python 2. six.u expects a string literal as input, whereas unicode can accept other types like bool and converts them to unicode.
So when value is a bool, six.u errors.

@cclauss

cclauss commented Jun 21, 2018

Copy link
Copy Markdown
Contributor Author

six.text_type() seems like a better substitute.

@dbieber

dbieber commented Jun 21, 2018

Copy link
Copy Markdown
Collaborator

Yeah, that looks right. Thanks.

cclauss pushed a commit to cclauss/python-fire that referenced this pull request Jun 22, 2018
dbieber pushed a commit that referenced this pull request Jun 22, 2018
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.

3 participants