-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
SSL recv_into requires the object to implement __len__ unlike socket one #84443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
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: if length is not given, it tries to call the __len__ of the object itself (not it's buffer protocol). |
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. |
…size != 1 (GH-20310) It is also no longer use __len__(). Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
…h itemsize != 1 (pythonGH-20310) It is also no longer use __len__(). (cherry picked from commit 812360f) Co-authored-by: Zackery Spytz <zspytz@gmail.com> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
…col with itemsize != 1 (pythonGH-20310) It is also no longer use __len__(). (cherry picked from commit 812360f) Co-authored-by: Zackery Spytz <zspytz@gmail.com> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
…h itemsize != 1 (pythonGH-20310) It is also no longer use __len__(). Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
…h itemsize != 1 (pythonGH-20310) It is also no longer use __len__(). Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
Linked PRs
The text was updated successfully, but these errors were encountered: