Skip to content

Commit ea1c36c

Browse files
committed
chore: make it more readable
1 parent 1c8315e commit ea1c36c

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/requests/models.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -596,9 +596,9 @@ def prepare_body(
596596
if not isinstance(body, bytes):
597597
body = body.encode("utf-8")
598598

599-
if (isinstance(data, Iterable) or hasattr(data, "__iter__")) and not isinstance(
600-
data, (str, bytes, list, tuple, Mapping)
601-
):
599+
# data that proxies attributes to underlying objects needs hasattr
600+
is_iterable = isinstance(data, Iterable) or hasattr(data, "__iter__")
601+
if is_iterable and not isinstance(data, (str, bytes, list, tuple, Mapping)):
602602
try:
603603
length = super_len(data)
604604
except (TypeError, AttributeError, UnsupportedOperation):

0 commit comments

Comments
 (0)