You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Roger Meier (JIRA)" <ji...@apache.org> on 2014/08/12 23:36:13 UTC

[jira] [Commented] (THRIFT-2659) python Test Server fails when throwing TException

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

Roger Meier commented on THRIFT-2659:
-------------------------------------

I guess we miss th following test defined here: test/ThriftTest.thrift
{noformat}
diff --git a/test/py/TestClient.py b/test/py/TestClient.py
index 87fede6..9c922aa 100755
--- a/test/py/TestClient.py
+++ b/test/py/TestClient.py
@@ -191,6 +191,12 @@ class AbstractTest(unittest.TestCase):
       #self.assertEqual(x_repr, 'Xception(errorCode=1001, message=\'Xception\')
 
     try:
+      self.client.testException('TException')
+      self.fail("should have gotten TException")
+    except TEception, x:
+      pass
+
+    try:
       self.client.testException("throw_undeclared")
       self.fail("should have thrown exception")
     except Exception: # type is undefined
{noformat}

> python Test Server fails when throwing TException
> -------------------------------------------------
>
>                 Key: THRIFT-2659
>                 URL: https://issues.apache.org/jira/browse/THRIFT-2659
>             Project: Thrift
>          Issue Type: Sub-task
>          Components: Python - Compiler, Python - Library, Test Suite
>            Reporter: Chamila Dilshan Wijayarathna
>              Labels: gsoc2014
>
> As ThriftTest.thrift has defined TestException has 3 scenarios.
> if arg == "Xception" throw Xception with errorCode = 1001 and message = arg
> else if arg == "TException" throw TException
> else do not throw anything
> But when testException("TException") is called, python server is failing saying 
> testException(TException)
> ERROR:root:This is a TException
> Traceback (most recent call last):
>   File "py/../../lib/py/build/lib.linux-x86_64-2.7/thrift/server/TServer.py", line 86, in serve
>     self.processor.process(iprot, oprot)
>   File "py/gen-py/ThriftTest/ThriftTest.py", line 1006, in process
>     self._processMap[name](self, seqid, iprot, oprot)
>   File "py/gen-py/ThriftTest/ThriftTest.py", line 1202, in process_testException
>     self._handler.testException(args.arg)
>   File "py/TestServer.py", line 115, in testException
>     raise TException(message='This is a TException')
> TException: This is a TException
> It looks like this causes since auto generated gen-py/ThriftTest/ThriftTest.py doesn't catch TException.
> def process_testException(self, seqid, iprot, oprot):
>     args = testException_args()
>     args.read(iprot)
>     iprot.readMessageEnd()
>     result = testException_result()
>     try:
>       self._handler.testException(args.arg)
>     except Xception, err1:
>       result.err1 = err1
>     oprot.writeMessageBegin("testException", TMessageType.REPLY, seqid)
>     result.write(oprot)
>     oprot.writeMessageEnd()
>     oprot.trans.flush()



--
This message was sent by Atlassian JIRA
(v6.2#6252)