Skip to content

Commit e025c84

Browse files
bwhitmandpgeorge
authored andcommitted
requests: Fix detection of iterators in chunked data requests.
Chunked detection does not work as generators never have an `__iter__` attribute. They do have `__next__`. Example that now works with this commit: def read_in_chunks(file_object, chunk_size=4096): while True: data = file_object.read(chunk_size) if not data: break yield data file = open(filename, "rb") r = requests.post(url, data=read_in_chunks(file))
1 parent 46748d2 commit e025c84

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

python-ecosys/requests/manifest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
metadata(version="0.8.0", pypi="requests")
1+
metadata(version="0.8.1", pypi="requests")
22

33
package("requests")

python-ecosys/requests/requests/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def request(
4545
parse_headers=True,
4646
):
4747
redirect = None # redirection url, None means no redirection
48-
chunked_data = data and getattr(data, "__iter__", None) and not getattr(data, "__len__", None)
48+
chunked_data = data and getattr(data, "__next__", None) and not getattr(data, "__len__", None)
4949

5050
if auth is not None:
5151
import ubinascii

0 commit comments

Comments
 (0)