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
 
     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: