Skip to content

Fix bug with socket.recv_into size == 0. #3397

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

Merged
merged 1 commit into from
Sep 14, 2020

Conversation

tannewt
Copy link
Member

@tannewt tannewt commented Sep 11, 2020

It returned 0 when it should have filled the buffer.

Python reference: https://docs.python.org/3/library/socket.html#socket.socket.recv_into

It returned 0 when it should have filled the buffer.

Python reference: https://docs.python.org/3/library/socket.html#socket.socket.recv_into
@tannewt tannewt added bug espressif applies to multiple Espressif chips labels Sep 11, 2020
@tannewt tannewt added this to the 6.x.x - Bug Fixes milestone Sep 11, 2020
@anecdata
Copy link
Member

Tested on Saola-R with latest Requests.

This change fixes the RuntimeError: Unable to read HTTP response. in Requests.

Copy link

@jepler jepler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This an improvement to Python3 compatibility. However, I note that standard Python signals an error when the specified size is nonzero and bigger than the buffer, which this code doesn't do (yet):

>>> import socket
>>> b = bytearray(7)
>>> s = socket.socket()
>>> s.recv_into(b, 8)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: buffer too small for requested bytes

Feel free to merge and treat this as a separate issue if desired.

@tannewt
Copy link
Member Author

tannewt commented Sep 14, 2020

@jepler Issue filed #3421 because it'd be a good first issue for someone.

@tannewt tannewt merged commit 3d8bac5 into adafruit:main Sep 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug espressif applies to multiple Espressif chips
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants