Author: Manuel Jacob <[email protected]>
Branch: py3.5-ssl-revdb
Changeset: r95991:664e95442ff7
Date: 2019-02-12 20:12 +0100
http://bitbucket.org/pypy/pypy/changeset/664e95442ff7/

Log:    Fix _SSLSocket.read() for buffers that can&#8217;t get their raw 
addresses
        taken (e.g. when running on top of RevDB).

diff --git a/lib_pypy/_cffi_ssl/_stdssl/__init__.py 
b/lib_pypy/_cffi_ssl/_stdssl/__init__.py
--- a/lib_pypy/_cffi_ssl/_stdssl/__init__.py
+++ b/lib_pypy/_cffi_ssl/_stdssl/__init__.py
@@ -453,7 +453,12 @@
                     raise OverflowError("maximum length can't fit in a C 
'int'")
                 if len(buffer_into) == 0:
                     return 0
-            mem = ffi.from_buffer(buffer_into)
+            try:
+                mem = ffi.from_buffer(buffer_into)
+                zero_copy = True
+            except TypeError:
+                mem = ffi.new("char[]", length)
+                zero_copy = False
 
         if sock:
             timeout = _socket_timeout(sock)
@@ -500,8 +505,10 @@
 
         if not buffer_into:
             return _bytes_with_len(mem, count)
-
-        return count
+        else:
+            if not zero_copy:
+                buffer_into[0:count] = ffi.buffer(mem)[0:count]
+            return count
 
     if HAS_ALPN:
         def selected_alpn_protocol(self):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to