Commits

Ralf Schmitt  committed a045c35

fallback to buffer if memoryview fails in _get_memory on python 2.7

fixes "python2.7 array.array doesn't support memoryview used in
gevent.socket.send" issue
(http://code.google.com/p/gevent/issues/detail?id=94)

  • Participants
  • Parent commits 1750d2f

Comments (0)

Files changed (1)

File gevent/socket.py

 
 if sys.version_info[:2] < (2, 7):
     _get_memory = buffer
+elif sys.version_info[:2] < (3, 0):
+    def _get_memory(string, offset):
+        try:
+            return memoryview(string)[offset:]
+        except TypeError:
+            return buffer(string, offset)
 else:
-
     def _get_memory(string, offset):
         return memoryview(string)[offset:]