[New-bugs-announce] [issue17575] HTTPConnection.send

dspublic@freemail.hu report at bugs.python.org
Fri Mar 29 17:25:03 CET 2013


New submission from dspublic at freemail.hu:

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

----------
messages: 185501
nosy: dspublic at freemail.hu
priority: normal
severity: normal
status: open
title: HTTPConnection.send
type: behavior
versions: Python 3.2, Python 3.3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17575>
_______________________________________


More information about the New-bugs-announce mailing list