avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ham...@apache.org
Subject svn commit: r942022 - in /hadoop/avro/trunk: CHANGES.txt lang/py/src/avro/ipc.py
Date Fri, 07 May 2010 07:53:29 GMT
Author: hammer
Date: Fri May  7 07:53:29 2010
New Revision: 942022

URL: http://svn.apache.org/viewvc?rev=942022&view=rev
Log:
AVRO-526. Fall back to pure Python StringIO if cStringIO is not available
(hammer via Esteve Fernandez)


Modified:
    hadoop/avro/trunk/CHANGES.txt
    hadoop/avro/trunk/lang/py/src/avro/ipc.py

Modified: hadoop/avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/CHANGES.txt?rev=942022&r1=942021&r2=942022&view=diff
==============================================================================
--- hadoop/avro/trunk/CHANGES.txt (original)
+++ hadoop/avro/trunk/CHANGES.txt Fri May  7 07:53:29 2010
@@ -33,6 +33,9 @@ Avro 1.4.0 (unreleased)
 
     AVRO-525. remove unused imports (hammer via Esteve Fernandez)
 
+    AVRO-526. Fall back to pure Python StringIO if cStringIO is not available
+    (hammer via Esteve Fernandez)
+
   BUG FIXES
     AVRO-461. Skipping primitives in the ruby side (jmhodges)
 

Modified: hadoop/avro/trunk/lang/py/src/avro/ipc.py
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/py/src/avro/ipc.py?rev=942022&r1=942021&r2=942022&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/py/src/avro/ipc.py (original)
+++ hadoop/avro/trunk/lang/py/src/avro/ipc.py Fri May  7 07:53:29 2010
@@ -17,7 +17,10 @@
 Support for inter-process calls.
 """
 import httplib
-import cStringIO
+try:
+  from cStringIO import StringIO
+except ImportError:
+  from StringIO import StringIO
 import struct
 from avro import io
 from avro import protocol
@@ -128,7 +131,7 @@ class Requestor(object):
     Writes a request message and reads a response or error message.
     """
     # build handshake and call request
-    buffer_writer = cStringIO.StringIO()
+    buffer_writer = StringIO()
     buffer_encoder = io.BinaryEncoder(buffer_writer)
     self.write_handshake_request(buffer_encoder)
     self.write_call_request(message_name, request_datum, buffer_encoder)
@@ -138,7 +141,7 @@ class Requestor(object):
     call_response = self.transceiver.transceive(call_request)
 
     # process the handshake and call response
-    buffer_decoder = io.BinaryDecoder(cStringIO.StringIO(call_response))
+    buffer_decoder = io.BinaryDecoder(StringIO(call_response))
     call_response_exists = self.read_handshake_response(buffer_decoder)
     if call_response_exists:
       return self.read_call_response(message_name, buffer_decoder)
@@ -275,9 +278,9 @@ class Responder(object):
     Called by a server to deserialize a request, compute and serialize
     a response or error. Compare to 'handle()' in Thrift.
     """
-    buffer_reader = cStringIO.StringIO(call_request)
+    buffer_reader = StringIO(call_request)
     buffer_decoder = io.BinaryDecoder(buffer_reader)
-    buffer_writer = cStringIO.StringIO()
+    buffer_writer = StringIO()
     buffer_encoder = io.BinaryEncoder(buffer_writer)
     error = None
     response_metadata = {}
@@ -326,7 +329,7 @@ class Responder(object):
         self.write_error(writers_schema, error, buffer_encoder)
     except schema.AvroException, e:
       error = AvroRemoteException(str(e))
-      buffer_encoder = io.BinaryEncoder(cStringIO.StringIO())
+      buffer_encoder = io.BinaryEncoder(StringIO())
       META_WRITER.write(response_metadata, buffer_encoder)
       buffer_encoder.write_boolean(True)
       self.write_error(SYSTEM_ERROR_SCHEMA, error, buffer_encoder)
@@ -397,7 +400,7 @@ class FramedReader(object):
   def read_framed_message(self):
     message = []
     while True:
-      buffer = cStringIO.StringIO()
+      buffer = StringIO()
       buffer_length = self._read_buffer_length()
       if buffer_length == 0:
         return ''.join(message)
@@ -483,7 +486,7 @@ class HTTPTransceiver(object):
     req_resource = '/'
     req_headers = {'Content-Type': 'avro/binary'}
 
-    req_body_buffer = FramedWriter(cStringIO.StringIO())
+    req_body_buffer = FramedWriter(StringIO())
     req_body_buffer.write_framed_message(message)
     req_body = req_body_buffer.writer.getvalue()
 



Mime
View raw message