summaryrefslogtreecommitdiffstats
path: root/Lib/http/client.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/http/client.py')
-rw-r--r--Lib/http/client.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/Lib/http/client.py b/Lib/http/client.py
index b7092de..fef7185 100644
--- a/Lib/http/client.py
+++ b/Lib/http/client.py
@@ -726,10 +726,17 @@ class HTTPConnection:
if self.debuglevel > 0:
print("sendIng a read()able")
encode = False
- if "b" not in str.mode:
- encode = True
- if self.debuglevel > 0:
- print("encoding file using iso-8859-1")
+ try:
+ mode = str.mode
+ except AttributeError:
+ # io.BytesIO and other file-like objects don't have a `mode`
+ # attribute.
+ pass
+ else:
+ if "b" not in mode:
+ encode = True
+ if self.debuglevel > 0:
+ print("encoding file using iso-8859-1")
while 1:
data = str.read(blocksize)
if not data: