From 3fd309a5c14e4cfbd96bea6c8e71b4958fe090bb Mon Sep 17 00:00:00 2001 From: Bruce Adams Date: Tue, 28 Nov 2023 13:17:49 -0500 Subject: [PATCH] Enhance `super_len` to count encoded bytes for str This fixes issue #6586 --- src/requests/utils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/requests/utils.py b/src/requests/utils.py index c3b123ea..a603a863 100644 --- a/src/requests/utils.py +++ b/src/requests/utils.py @@ -134,6 +134,9 @@ def super_len(o): total_length = None current_position = 0 + if isinstance(o, str): + o = o.encode("utf-8") + if hasattr(o, "__len__"): total_length = len(o)