Attila Gerendi added the comment:

Renamed the report since it's unsafe for sure.

This problem was previously called: Avoid unnecessary and possibly unsafe code 
from http.client.HTTPConnection.send. 


Imagine that the data parameter from HTTPConnection it's a file like object but 
it's not iterable, maybe some custom data wrapper.

the if hasattr(data, "read"): True branch will correctly send out the response 
then unnecessary continue to:

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))

and crash!

----------
resolution:  -> remind
title: Avoid unnecessary and possibly unsafe code from 
http.client.HTTPConnection.send -> http.client.HTTPConnection.send double send 
data
type: performance -> crash

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue16904>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to