From: David Reiss Date: Tue, 12 May 2009 02:17:43 +0000 (+0000) Subject: THRIFT-495. python: Raise a TTransportException if TSocket is not open X-Git-Tag: 0.2.0~115 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=a043be31fc88b5f3777b3311c64e9fffbe9de5b1;p=common%2Fthrift.git THRIFT-495. python: Raise a TTransportException if TSocket is not open Previously, TSocket.write would raise an AttributeError if the transport had not been opened. A TTransportException with the code set to NOT_OPEN is more appropriate. The cost of the check should be negligible, since TSocket.write is already fairly expensive (it does a system call). git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@773762 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/lib/py/src/transport/TSocket.py b/lib/py/src/transport/TSocket.py index 4645a023..5e58825f 100644 --- a/lib/py/src/transport/TSocket.py +++ b/lib/py/src/transport/TSocket.py @@ -95,6 +95,8 @@ class TSocket(TSocketBase): return buff def write(self, buff): + if not self.handle: + raise TTransportException(TTransportException.NOT_OPEN, 'Transport not open') sent = 0 have = len(buff) while sent < have: