Mercurial > cpython-lru_cache-weakref
diff Lib/http/client.py @ 56293:a17cd9fcdd46 3.1
Merged revisions 75137 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
................
r75137 | antoine.pitrou | 2009-09-29 20:44:53 +0200 (mar., 29 sept. 2009) | 14 lines
[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.
........
................
| author | Antoine Pitrou <solipsis@pitrou.net> |
|---|---|
| date | Tue, 29 Sep 2009 19:02:24 +0000 |
| parents | 266d7dc3d655 |
| children | dc1aadf9fa4a |
line wrap: on
line diff
--- a/Lib/http/client.py Tue Sep 29 18:56:36 2009 +0000 +++ b/Lib/http/client.py Tue Sep 29 19:02:24 2009 +0000 @@ -726,10 +726,17 @@ 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:
