THRIFT-2825 Supplying unicode to python Thrift client can cause next request arguments to get overwritten

Make sure we clear wbuf on exception, so it doesn't contain a
partial function call.

Patch: Zach Steindler

This closes #282
diff --git a/lib/py/src/transport/TTransport.py b/lib/py/src/transport/TTransport.py
index 5ab2fde..5914aca 100644
--- a/lib/py/src/transport/TTransport.py
+++ b/lib/py/src/transport/TTransport.py
@@ -160,7 +160,12 @@
     return self.__rbuf.read(sz)
 
   def write(self, buf):
-    self.__wbuf.write(buf)
+    try:
+      self.__wbuf.write(buf)
+    except Exception as e:
+      # on exception reset wbuf so it doesn't contain a partial function call
+      self.__wbuf = StringIO()
+      raise e
 
   def flush(self):
     out = self.__wbuf.getvalue()