You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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))
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.
ifhasattr(data, "read") :
ifself.debuglevel>0:
print("sendIng a read()able")
encode=Falsetry:
mode=data.modeexceptAttributeError:
# io.BytesIO and other file-like objects don't have a `mode`# attribute.passelse:
if"b"notinmode:
encode=Trueifself.debuglevel>0:
print("encoding file using iso-8859-1")
while1:
datablock=data.read(blocksize)
ifnotdatablock:
breakifencode:
datablock=datablock.encode("iso-8859-1")
self.sock.sendall(datablock)
return
dspublicfreemailhu commented on Apr 14, 2013
dspublicfreemailhumannequin
MannequinAuthor
More actions
Thank you Stephen.Tu for information. I think so, the "return" has been found ;-)
Activity
dspublicfreemailhu commentedon Mar 29, 2013
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))
StephenTu commentedon Apr 13, 2013
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.
dspublicfreemailhu commentedon Apr 14, 2013
Thank you Stephen.Tu for information. I think so, the "return" has been found ;-)