Github user nsuke commented on a diff in the pull request:

    https://github.com/apache/thrift/pull/673#discussion_r44134486
  
    --- Diff: lib/py/test/thrift_json.py ---
    @@ -0,0 +1,28 @@
    +from thrift import Thrift
    +from thrift.protocol.TJSONProtocol import TJSONProtocol
    +from thrift.transport import TTransport
    +
    +import unittest
    +
    +#
    +# In order to run the test under Windows. We need to create symbolic link
    +# name 'thrift' to '../src' folder by using:
    +#
    +# mklink /D thrift ..\src
    +#
    +
    +class TestJSONString(unittest.TestCase):
    +
    +  def test_escaped_unicode_string(self):
    +    unicode_json = '"hello \\u0e01\\u0e02\\u0e03\\ud835\\udcab unicode"'
    +    unicode_text = u'hello \u0e01\u0e02\u0e03\U0001D4AB unicode'
    +
    +    buf = TTransport.TMemoryBuffer(unicode_json)
    +    transport = TTransport.TBufferedTransportFactory().getTransport(buf)
    +    protocol = TJSONProtocol(transport)
    +
    +    self.assertEqual(protocol.readString(), unicode_text)
    --- End diff --
    
    Since the other protocols' `readString` returned string, we cannot make 
TJSONProtocol alone return unicode.
    (FYI unicode in Thrift python2 is handled by "utf8string" generator option.)
    
    Now that we have Python3, it is valid as is for Python3 (since unicode and 
string is equivalent in py3) but still needs the modification for Python2.
    To do this you may want to look at `testString` in test/py/TestClient.py 
for Python2/3 switch.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to