diff options
author | Zackery Spytz <zspytz@gmail.com> | 2023-11-27 17:15:39 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-27 17:15:39 (GMT) |
commit | 812360fddda86d7aff5823f529ab720f57ddc411 (patch) | |
tree | c43b90aa73a8bb1942f10a205f508d50e39fa175 /Lib/ssl.py | |
parent | 22e411e1d107f79a0904d41a489a82355a39b5de (diff) | |
download | cpython-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.py | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -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( |