summaryrefslogtreecommitdiffstats
path: root/Lib/ssl.py
diff options
context:
space:
mode:
authorZackery Spytz <zspytz@gmail.com>2023-11-27 17:15:39 (GMT)
committerGitHub <noreply@github.com>2023-11-27 17:15:39 (GMT)
commit812360fddda86d7aff5823f529ab720f57ddc411 (patch)
treec43b90aa73a8bb1942f10a205f508d50e39fa175 /Lib/ssl.py
parent22e411e1d107f79a0904d41a489a82355a39b5de (diff)
downloadcpython-812360fddda86d7aff5823f529ab720f57ddc411.zip
cpython-812360fddda86d7aff5823f529ab720f57ddc411.tar.gz
cpython-812360fddda86d7aff5823f529ab720f57ddc411.tar.bz2
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>
Diffstat (limited to 'Lib/ssl.py')
-rw-r--r--Lib/ssl.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/Lib/ssl.py b/Lib/ssl.py
index 62e5585..36fca9d 100644
--- a/Lib/ssl.py
+++ b/Lib/ssl.py
@@ -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(