You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SSL recv_into requires the object to implement __len__ unlike socket one #84443
I am writing this as a bug, as I have an object which implements the buffer protocol but not the __len__.
SSL's recv_into seems to require the buffer object to implement __len__, but this is unlike the socket recv_into which uses the buffer protocol length.
Activity
tzickel commentedon Apr 12, 2020
I am writing this as a bug, as I have an object which implements the buffer protocol but not the __len__.
SSL's recv_into seems to require the buffer object to implement __len__, but this is unlike the socket recv_into which uses the buffer protocol length.
Here is the socket.recv_into implementation:
cpython/Modules/socketmodule.c
Line 3556 in 402e1cd
as you can see, the length is optional, and it not given, it takes it from the buffer protocol length.
But here is SSL recv_into implementation:
https://github.com/python/cpython/blob/master/Lib/ssl.py#L1233
if length is not given, it tries to call the __len__ of the object itself (not it's buffer protocol).
serhiy-storchaka commentedon Apr 30, 2020
Yes, it is a bug. __len__ can return a value different from the amount of bytes (in array.array, memoryview).
len(buffer) can be replaced with memoryview(buffer).nbytes, but maybe we could keep None and let the lower level to handle it.
gh-84443: SSLSocket.recv_into() now support buffer protocol with item…
pythongh-84443: SSLSocket.recv_into() now support buffer protocol wit…
[3.11] pythongh-84443: SSLSocket.recv_into() now support buffer proto…
[3.12] gh-84443: SSLSocket.recv_into() now support buffer protocol wi…
[3.11] gh-84443: SSLSocket.recv_into() now support buffer protocol wi…
pythongh-84443: SSLSocket.recv_into() now support buffer protocol wit…
pythongh-84443: SSLSocket.recv_into() now support buffer protocol wit…