summaryrefslogtreecommitdiffstats
path: root/Lib/http
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2009-09-29 18:44:53 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2009-09-29 18:44:53 (GMT)
commitead1d62d3239109656d4b3fd2f99461dddb2fae1 (patch)
tree96627b09fe56dd5d6d2c0aed02d74e9b7079e008 /Lib/http
parent8da3cac4a054e7edccfecce71f4f526e329c730f (diff)
downloadcpython-ead1d62d3239109656d4b3fd2f99461dddb2fae1.zip
cpython-ead1d62d3239109656d4b3fd2f99461dddb2fae1.tar.gz
cpython-ead1d62d3239109656d4b3fd2f99461dddb2fae1.tar.bz2
[NOTE: the original bug doesn't exist in py3k but this adds Kirk's tests and fixes
another bug in the process] Merged revisions 75134 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r75134 | antoine.pitrou | 2009-09-29 19:48:18 +0200 (mar., 29 sept. 2009) | 4 lines Issue #6790: Make it possible again to pass an `array.array` to `httplib.HTTPConnection.send`. Patch by Kirk McDonald. ........
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 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: