[ https://issues.apache.org/jira/browse/THRIFT-3500?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15069239#comment-15069239 ]
ASF GitHub Bot commented on THRIFT-3500: ---------------------------------------- GitHub user johnlockwood-wf opened a pull request: https://github.com/apache/thrift/pull/756 THRIFT-3500: Strings unicode py2 As the test shows this makes Thrift protocols treat Strings as unicode in Python 2 which is essentially equivalent as the str in Python 3. Indeed Python 3.5 now treats u"hello" as a str literal, just as Python 2 treats it as a unicode literal. The python 2 standard lib contains the json package, that, when loading JSON, deserializes strings into unicode objects, where the TJSONProtocol deserializes them into utf-8 encoded bytes without this change. https://issues.apache.org/jira/browse/THRIFT-3500 You can merge this pull request into a Git repository by running: $ git pull https://github.com/johnlockwood-wf/thrift strings-unicode-py2 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/thrift/pull/756.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #756 ---- commit dfd8f2b6f9d283b74d4b59d9ec0899d63f54402a Author: John.Lockwood <john.lockw...@webfilings.com> Date: 2015-12-20T01:12:59Z Make a String type come from a JSON String. JSON String is equivalent to unicode in Py2 and str Py3 Expect the type being transformed into JSON String is either ASCII str or unicode in Py2 and str in Py3. commit 1ebbed5fea9c23f3312f5a7adb160c7bc9c842fb Author: John.Lockwood <john.lockw...@webfilings.com> Date: 2015-12-20T01:39:48Z Improve the string/binary compatibility functions This makes them concept equivalent across Py2/Py3 ---- > Protocols in Python 2 do not treat Strings as unicode. > ------------------------------------------------------ > > Key: THRIFT-3500 > URL: https://issues.apache.org/jira/browse/THRIFT-3500 > Project: Thrift > Issue Type: Bug > Components: Python - Library > Affects Versions: 0.9.3, 1.0 > Reporter: John Lockwood > > Service methods which take a string type param, should expect a unicode > object in Python 2, but instead expect str. > Service methods which return string type objects should return a unicode > object in Python 2, but instead return str. > When making service calls with Python 2, passing in a unicode object with > non-ascii chars will raise an exception. -- This message was sent by Atlassian JIRA (v6.3.4#6332)