[ 
https://issues.apache.org/jira/browse/THRIFT-3721?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15188191#comment-15188191
 ] 

Jason Heimann edited comment on THRIFT-3721 at 3/9/16 10:28 PM:
----------------------------------------------------------------

Specifying "-gen py:utf8_strings" with my thrift invocation did not solve the 
issue.

The stack trace takes me into the transport layer of Thrift:

{code}
  <snip>
  File "build/bdist.linux-x86_64/egg/<my generated Thrift>/ttypes.py", line 
459, in write
  File 
"/home/jheimann/altair/thriftenv/local/lib/python2.7/site-packages/thrift/protocol/TProtocolDecorator.py",
 line 32, in <lambda>
    return lambda *args, **kwargs: self._wrap(member, args, kwargs)
  File 
"/home/jheimann/altair/thriftenv/local/lib/python2.7/site-packages/thrift/protocol/TProtocolDecorator.py",
 line 39, in _wrap
    result = func(*args, **kwargs)
  File 
"/home/jheimann/altair/thriftenv/local/lib/python2.7/site-packages/thrift/protocol/TBinaryProtocol.py",
 line 123, in writeString
    self.trans.write(str)
  File 
"/home/jheimann/altair/thriftenv/local/lib/python2.7/site-packages/thrift/transport/TSocket.py",
 line 130, in write
    plus = self.handle.send(buff)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: 
ordinal not in range(128)
{code}

The code that generated this error is approximately:
{code}
    socket = TSocket('<my server>', 12345)
    transport = TBinaryProtocol(socket)
    protocol = TMultiplexedProtocol(transport, '<my protocol>')
    client = <my generated Thrift service>.Client(protocol)
    client.<my endpoint>(param=u'三木 昌彦')
{code}


was (Author: table-delete):
Specifying "-gen py:utf8_strings" with my thrift invocation did not solve the 
issue.

The stack trace takes me into the transport layer of Thrift:

{code}
  File "build/bdist.linux-x86_64/egg/<my generated Thrift>/ttypes.py", line 
459, in write
  File 
"/home/jheimann/altair/thriftenv/local/lib/python2.7/site-packages/thrift/protocol/TProtocolDecorator.py",
 line 32, in <lambda>
    return lambda *args, **kwargs: self._wrap(member, args, kwargs)
  File 
"/home/jheimann/altair/thriftenv/local/lib/python2.7/site-packages/thrift/protocol/TProtocolDecorator.py",
 line 39, in _wrap
    result = func(*args, **kwargs)
  File 
"/home/jheimann/altair/thriftenv/local/lib/python2.7/site-packages/thrift/protocol/TBinaryProtocol.py",
 line 123, in writeString
    self.trans.write(str)
  File 
"/home/jheimann/altair/thriftenv/local/lib/python2.7/site-packages/thrift/transport/TSocket.py",
 line 130, in write
    plus = self.handle.send(buff)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: 
ordinal not in range(128)
{code}

The code that generated this error is approximately:
{code}
    socket = TSocket('<my server>', 12345)
    transport = TBinaryProtocol(socket)
    protocol = TMultiplexedProtocol(transport, '<my protocol>')
    client = <my generated Thrift service>.Client(protocol)
    client.<my endpoint>(param=u'三木 昌彦')
{code}

> CLONE - why not add unicode strings support to python directly?
> ---------------------------------------------------------------
>
>                 Key: THRIFT-3721
>                 URL: https://issues.apache.org/jira/browse/THRIFT-3721
>             Project: Thrift
>          Issue Type: Bug
>          Components: Python - Library
>    Affects Versions: 0.8, 0.9.2
>         Environment: Ubuntu 14.04.03 LTS, Ubuntu 15.10
>            Reporter: Jason Heimann
>            Assignee: Jake Farrell
>              Labels: python, unicode
>
> i install thrift python lib by easy_install
> but in version0.8,I still didn't see the 
> patch(https://issues.apache.org/jira/browse/THRIFT-395) be added in the lib
> I had to hack the code follow the patch manually 
> (https://issues.apache.org/jira/secure/attachment/12404198/0003-THRIFT-395.-python-Phase-Two-of-support-for-unicode.patch)
> Can any of the developers fix the problem?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to