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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy