Author fviard
Recipients fviard
Date 2013-10-03.17:12:38
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1380820358.99.0.777618727237.issue19154@psf.upfronthosting.co.za>
In-reply-to
Content
In Lib/http/client.py +682    (Formerly httplib)

    def fileno(self):
        return self.fp.fileno()

This function should be modified to be able to handle the case where the http request is already completed and so "fp" is closed. Ex.:
    def fileno(self):
        if self.fp:
            return self.fp.fileno()
        else:
            return -1

I encountered the issue in the following context:
while 1:
  read_list = select([req], ...)[0]
  if read_list:
    req.read(CHUNK_SIZE)
  ...

Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/nappstore/server_comm.py", line 211, in download_file
    ready = select.select([req], [], [], timeout)[0]
  File "/usr/lib/python2.7/socket.py", line 313, in fileno
    return self._sock.fileno()
  File "/usr/lib/python2.7/httplib.py", line 655, in fileno
    return self.fp.fileno()
  AttributeError: 'NoneType' object has no attribute 'fileno'

For the returned value, I'm not sure because there is currently 2 different cases for other objects returning a fileno. 
In Lib/fileinput.py:
  -1 is returned in case of ValueError (no fileno value as fp was closed)
but in Lib/socket.py:
  ValueError is raised in that case and default value for fileno for a socket is None
History
Date User Action Args
2013-10-03 17:12:39fviardsetrecipients: + fviard
2013-10-03 17:12:38fviardsetmessageid: <1380820358.99.0.777618727237.issue19154@psf.upfronthosting.co.za>
2013-10-03 17:12:38fviardlinkissue19154 messages
2013-10-03 17:12:38fviardcreate