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

ASF GitHub Bot commented on THRIFT-2825:
----------------------------------------

GitHub user steiza opened a pull request:

    https://github.com/apache/thrift/pull/282

    Fix for Python Thrift client when it encounters an exception on write

    Make sure we clear wbuf on exception, so it doesn't contain a partial 
function call.
    
    As the branch name suggests, this is for 
https://issues.apache.org/jira/browse/THRIFT-2825. This is my first time 
contributing to Thrift, so let me know if there's something I should be doing 
differently!

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/steiza/thrift THRIFT-2825

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/thrift/pull/282.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 #282
    
----
commit d30b814ba2c07f672a3dfe4f49f8153c06e84c57
Author: Zach Steindler <[email protected]>
Date:   2014-11-24T18:00:47Z

    Fix for Python Thrift client when it encounters an exception on write
    
    Make sure we clear wbuf on exception, so it doesn't contain a
    partial function call.

----


> Supplying unicode to python Thrift client can cause next request arguments to 
> get overwritten
> ---------------------------------------------------------------------------------------------
>
>                 Key: THRIFT-2825
>                 URL: https://issues.apache.org/jira/browse/THRIFT-2825
>             Project: Thrift
>          Issue Type: Bug
>          Components: Python - Library
>            Reporter: Zach Steindler
>         Attachments: thrift_example.tar.gz
>
>
> The python thrift client expects bytestrings instead of unicode. However, if 
> you accidentally supply unicode instead of bytestrings it messes the 
> arguments for the next thrift call on that client object, even if all the 
> arguments are ASCII / bytestrings.
> For example, I have some python thrift client code that looks like this:
> {noformat}
>     try:
>         client.example_function('first_call_arg1', u'☃', 'first_call_arg3')
>     except UnicodeEncodeError:
>         pass # This is what we expect to happen
>     client.example_function('second_call_arg1', 'second_call_arg2', 
> 'second_call_arg3')
> {noformat}
> What I expect to see on the server side is this:
> {noformat}
> Example function called with second_call_arg1 second_call_arg2 
> second_call_arg3
> {noformat}
> But what I see is this:
> {noformat}
> Example function called with first_call_arg1 � None
> {noformat}
> I'm using the Thrift compiler version 0.9.2 and python thrift library version 
> 0.9.1.



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

Reply via email to