You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by Dan Gould <dl...@dangould.com> on 2010/10/05 01:30:46 UTC
utf8strings in Thrift 0.5.0-RC1
Hi,
I'm invoking Thrift as
$ thrift --gen py:new_style,utf8strings ...
However, I'm getting this exception when sending:
File "model/graphdb/graphdb/Graph.py", line 923, in send_update_person
args.write(self._oprot)
File "model/graphdb/graphdb/Graph.py", line 5334, in write
oprot.writeString(self.one_line_bio)
File
"hsn/hsn_virtualenv/lib/python2.6/site-packages/thrift/protocol/TBinaryProtocol.py",
line 123, in writeString
self.trans.write(str)
File
"hsn/hsn_virtualenv/lib/python2.6/site-packages/thrift/transport/TTransport.py",
line 164, in write
self.__wbuf.write(buf)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in
position 1: ordinal not in range(128)
I expected it to send UTF-8 and that line 5334 in that traceback would read:
oprot.writeString(self.one_line_bio.encode('utf-8'))
per https://issues.apache.org/jira/browse/THRIFT-395
and, specifically
http://svn.apache.org/viewvc/incubator/thrift/trunk/compiler/cpp/src/generate/t_py_generator.cc
: 1998
Am I missing something I have to do to enable unicode support in Thrift
(sorry, I'm a beginner)?
Thanks
Re: utf8strings in Thrift 0.5.0-RC1
Posted by Dan Gould <dl...@dangould.com>.
I think I may have found it. It turns out it's my fault. Apparently
where it writes things in a different place than the old version of
thrift I was using, so my code was loading the old versions of the
files. Thrift with unicode makes so much more sense...
Thanks all for looking.
On 10/5/10 5:18 PM, Bryan Duxbury wrote:
> Any pythonistas that can chime in here?
>
> On Mon, Oct 4, 2010 at 4:30 PM, Dan Gould<dl...@dangould.com> wrote:
>
>> Hi,
>>
>> I'm invoking Thrift as
>> $ thrift --gen py:new_style,utf8strings ...
>>
>> However, I'm getting this exception when sending:
>> File "model/graphdb/graphdb/Graph.py", line 923, in send_update_person
>> args.write(self._oprot)
>> File "model/graphdb/graphdb/Graph.py", line 5334, in write
>> oprot.writeString(self.one_line_bio)
>> File
>> "hsn/hsn_virtualenv/lib/python2.6/site-packages/thrift/protocol/TBinaryProtocol.py",
>> line 123, in writeString
>> self.trans.write(str)
>> File
>> "hsn/hsn_virtualenv/lib/python2.6/site-packages/thrift/transport/TTransport.py",
>> line 164, in write
>> self.__wbuf.write(buf)
>> UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in
>> position 1: ordinal not in range(128)
>>
>> I expected it to send UTF-8 and that line 5334 in that traceback would
>> read:
>> oprot.writeString(self.one_line_bio.encode('utf-8'))
>>
>> per https://issues.apache.org/jira/browse/THRIFT-395
>> and, specifically
>>
>> http://svn.apache.org/viewvc/incubator/thrift/trunk/compiler/cpp/src/generate/t_py_generator.cc: 1998
>>
>> Am I missing something I have to do to enable unicode support in Thrift
>> (sorry, I'm a beginner)?
>>
>> Thanks
>>
Re: utf8strings in Thrift 0.5.0-RC1
Posted by Bryan Duxbury <br...@rapleaf.com>.
Any pythonistas that can chime in here?
On Mon, Oct 4, 2010 at 4:30 PM, Dan Gould <dl...@dangould.com> wrote:
> Hi,
>
> I'm invoking Thrift as
> $ thrift --gen py:new_style,utf8strings ...
>
> However, I'm getting this exception when sending:
> File "model/graphdb/graphdb/Graph.py", line 923, in send_update_person
> args.write(self._oprot)
> File "model/graphdb/graphdb/Graph.py", line 5334, in write
> oprot.writeString(self.one_line_bio)
> File
> "hsn/hsn_virtualenv/lib/python2.6/site-packages/thrift/protocol/TBinaryProtocol.py",
> line 123, in writeString
> self.trans.write(str)
> File
> "hsn/hsn_virtualenv/lib/python2.6/site-packages/thrift/transport/TTransport.py",
> line 164, in write
> self.__wbuf.write(buf)
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in
> position 1: ordinal not in range(128)
>
> I expected it to send UTF-8 and that line 5334 in that traceback would
> read:
> oprot.writeString(self.one_line_bio.encode('utf-8'))
>
> per https://issues.apache.org/jira/browse/THRIFT-395
> and, specifically
>
> http://svn.apache.org/viewvc/incubator/thrift/trunk/compiler/cpp/src/generate/t_py_generator.cc: 1998
>
> Am I missing something I have to do to enable unicode support in Thrift
> (sorry, I'm a beginner)?
>
> Thanks
>