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

It is also no longer use __len__().

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
Zackery Spytz 2023-11-27 09:15:39 -08:00 committed by GitHub
parent 22e411e1d1
commit 812360fddd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 4 deletions

View file

@ -1270,10 +1270,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(