Skip to content

Commit

Permalink
Enhance super_len to count encoded bytes for str
Browse files Browse the repository at this point in the history
This is a possible fix for issue #6586
  • Loading branch information
bruceadams committed Nov 28, 2023
1 parent f670704 commit 0216ae7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/requests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ def super_len(o):
total_length = None
current_position = 0

if hasattr(o, "__len__"):
if isinstance(o, str):
total_length = len(o.encode("utf-8"))

elif hasattr(o, "__len__"):
total_length = len(o)

elif hasattr(o, "len"):
Expand Down

0 comments on commit 0216ae7

Please sign in to comment.