Closed steve-osfda closed 1 week ago
PS A put using a file descriptor as the data argument (opened 'rb' to a .json file...) works...
PPS I also tried returning byte strings, even though the documentation example does not do that, and it also fails, with a 400, bad request...
Hi @steve-osfda, this issue was patched in 2.29.0 early last year. If you update to a more recent version, you should no longer encounter this issue.
I would also suggest double checking your generator is actually producing what you're expecting. Your return
will not be included in the generator, only the StopIteration
exception raised at the end. You're only sending {"field": "value",'
over the wire which is likely the cause of your 400.
That was the ticket for the version that returned bytes! A generator needs an [implicit] return None
I will run with the bytes-encloded return for now (checking the requests version and act accordingly...) Debian bookworm stable right now uses 2.28.
Thank you so much for your speedy response!
I made a generator function that returns str chunks; I passed it to data [...data=my_func()...], and it eventually comes back with the error "memoryview: a bytes-like object is required, not 'str'" (debug statements indicate this is happening on the first yield...)
Documentation indicates this is the way to do it: https://docs.python-requests.org/en/latest/user/advanced/#chunk-encoded-requests
Expected Result
No error!
Actual Result
The error "memoryview: a bytes-like object is required, not 'str'".
Reproduction Steps
System Information