summaryrefslogtreecommitdiffstats
path: root/Lib/http
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/http')
-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 2418340..42da984 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: