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

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

jeking3 closed pull request #1632: THRIFT-4670: Twisted, slots, and void method 
fails with "object has no attribute 'success'"
URL: https://github.com/apache/thrift/pull/1632
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/compiler/cpp/src/thrift/generate/t_py_generator.cc 
b/compiler/cpp/src/thrift/generate/t_py_generator.cc
index 9c82b6cf2a..f0a153ca8b 100644
--- a/compiler/cpp/src/thrift/generate/t_py_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_py_generator.cc
@@ -1961,8 +1961,10 @@ void 
t_py_generator::generate_process_function(t_service* tservice, t_function*
       indent(f_service_) << "def write_results_success_" << 
tfunction->get_name()
                          << "(self, success, result, seqid, oprot):" << endl;
       indent_up();
-      f_service_ << indent() << "result.success = success" << endl
-                 << indent() << "oprot.writeMessageBegin(\"" << 
tfunction->get_name()
+      if (!tfunction->get_returntype()->is_void()) {
+        f_service_ << indent() << "result.success = success" << endl;
+      }
+      f_service_ << indent() << "oprot.writeMessageBegin(\"" << 
tfunction->get_name()
                  << "\", TMessageType.REPLY, seqid)" << endl
                  << indent() << "result.write(oprot)" << endl
                  << indent() << "oprot.writeMessageEnd()" << endl


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Twisted, slots, and void method fails with "object has no attribute 'success'"
> ------------------------------------------------------------------------------
>
>                 Key: THRIFT-4670
>                 URL: https://issues.apache.org/jira/browse/THRIFT-4670
>             Project: Thrift
>          Issue Type: Bug
>          Components: Python - Compiler
>    Affects Versions: 0.9.3, 0.10.0, 0.11.0
>            Reporter: Palmer
>            Priority: Minor
>
> When generating Twisted code for a void method, the compiler accidentally 
> assigns a value to the result.success field of the result object, even 
> though, as a void method, there is no success value and the result object has 
> no such field. If the slots option is not specified as well, this does not 
> cause a problem, it just sets a new field that is never used. However, with 
> the slots option, attempting to set this undefined field causes the errorĀ 
> "object has no attribute 'success'"



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to