diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2023-11-27 17:41:05 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-27 17:41:05 (GMT) |
commit | 6d9b1819b84a0285ed706d11b1f7060ddf141355 (patch) | |
tree | 9da9194c0438780afd1d659ae156bcd3ae568638 /Lib/ssl.py | |
parent | 62e430af9eca7eddafc1f73dd8f7af289ffdf097 (diff) | |
download | cpython-6d9b1819b84a0285ed706d11b1f7060ddf141355.zip cpython-6d9b1819b84a0285ed706d11b1f7060ddf141355.tar.gz cpython-6d9b1819b84a0285ed706d11b1f7060ddf141355.tar.bz2 |
[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 812360fddda86d7aff5823f529ab720f57ddc411)
Co-authored-by: Zackery Spytz <zspytz@gmail.com>
Diffstat (limited to 'Lib/ssl.py')
-rw-r--r-- | Lib/ssl.py | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -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( |