[3.11] gh-84443: SSLSocket.recv_into() now support buffer protocol with itemsize != 1 (GH-20310) (GH-112459)

It is also no longer use __len__().

(cherry picked from commit 812360fddd)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
This commit is contained in:
Serhiy Storchaka 2023-11-27 19:41:05 +02:00 committed by GitHub
parent 62e430af9e
commit 6d9b1819b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 4 deletions

View file

@ -1299,10 +1299,14 @@ class SSLSocket(socket):
def recv_into(self, buffer, nbytes=None, flags=0):
self._checkClosed()
if buffer and (nbytes is None):
nbytes = len(buffer)
elif nbytes is None:
nbytes = 1024
if nbytes is None:
if buffer is not None:
with memoryview(buffer) as view:
nbytes = view.nbytes
if not nbytes:
nbytes = 1024
else:
nbytes = 1024
if self._sslobj is not None:
if flags != 0:
raise ValueError(