[issue3243] Support iterable bodies in httplib
Antoine Pitrou
report at bugs.python.org
Mon Nov 29 17:00:08 CET 2010
Antoine Pitrou <pitrou at free.fr> added the comment:
Thanks for the patch.
First, you don't need to support str, since sockets only accept binary strings (not unicode).
Second, I think it's simpler and more generic to do something like:
try:
self.sock.sendall(data)
except TypeError:
try:
it = iter(data)
except TypeError:
raise TypeError("data should be a bytes-like object or "
"an iterable, got %r" % type(it))
for d in t:
self.sock.sendall(d)
----------
nosy: +pitrou
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3243>
_______________________________________
More information about the Python-bugs-list
mailing list