Fix UnicodeDecodeError in Python 2 with Object Macros - #28
Closed
kirsle wants to merge 6 commits into
Closed
Conversation
kirsle
force-pushed
the
bug/python-macro-text-type
branch
from
July 8, 2016 20:52
3deb2a1 to
8a2f239
Compare
kirsle
force-pushed
the
bug/python-macro-text-type
branch
from
July 8, 2016 20:58
37d2186 to
5ad6d6c
Compare
Member
Author
|
Python nightly (3.6) keeps failing due to what I can only hope is a temporary problem in Python nightly (it thinks having a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes a bug for Python 2 where a Python object macro was unable to return a Unicode string, due to the Python macro handler casting all return values as
str()type, which in Python 2, assumes ASCII, and it would raise aUnicodeDecodeError.Instead the return value is casted to
six.text_typewhich will beunicodein Python 2 andstrin Python 3.The following RiveScript example code demonstrates the original problem and that this change fixes it:
Expected result: