Issue 17575: HTTPConnection.send - Python tracker (original) (raw)
Issue17575
Created on 2013-03-29 16:25 by dspublic@freemail.hu, last changed 2022-04-11 14:57 by admin. This issue is now closed.
Messages (3) | ||
---|---|---|
msg185501 - (view) | Author: dspublic@freemail.hu (dspublic@freemail.hu) | Date: 2013-03-29 16:25 |
http.client modul, HTTPConnection object, send method Missing an "else" for self.sock.sendall(data) try block. ... if hasattr(data, "read") : if self.debuglevel > 0: print("sendIng a read()able") encode = False try: mode = data.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: datablock = data.read(blocksize) if not datablock: break if encode: datablock = datablock.encode("iso-8859-1") self.sock.sendall(datablock) else: #missing else try: self.sock.sendall(data) except TypeError: if isinstance(data, collections.Iterable): for d in data: self.sock.sendall(d) else: raise TypeError("data should be a bytes-like object " "or an iterable, got %r" % type(data)) | ||
msg186794 - (view) | Author: Stephen Tu (Stephen.Tu) * | Date: 2013-04-13 18:49 |
I don't think this is a bug anymore in the codebase- looking at Lib/http/client.py, if hasattr(data, "read") is true, then the branch will return unconditionally. if hasattr(data, "read") : if self.debuglevel > 0: print("sendIng a read()able") encode = False try: mode = data.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: datablock = data.read(blocksize) if not datablock: break if encode: datablock = datablock.encode("iso-8859-1") self.sock.sendall(datablock) return | ||
msg186949 - (view) | Author: dspublic@freemail.hu (dspublic@freemail.hu) | Date: 2013-04-14 20:13 |
Thank you Stephen.Tu for information. I think so, the "return" has been found ;-) |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:57:43 | admin | set | github: 61775 |
2013-04-14 20:13:05 | dspublic@freemail.hu | set | status: open -> closedresolution: fixedmessages: + |
2013-04-13 18:49:07 | Stephen.Tu | set | nosy: + Stephen.Tumessages: + |
2013-03-29 16:49:36 | Rosuav | set | nosy: + Rosuav |
2013-03-29 16:25:03 | dspublic@freemail.hu | create |