Author terry.reedy
Recipients docs@python, fviard, r.david.murray, terry.reedy
Date 2013-10-07.20:13:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1381176811.46.0.758787673744.issue19154@psf.upfronthosting.co.za>
In-reply-to
Content
We are both talking about 2.7 httplib.HTTPResponse.fileno. I should have said that users should try: ...fileno(); except AttributeError rather than ValueError. Any caller can understand AttributeError as well as ValueError or any other exception.

It is not an error for a python function to raise an exception. In fact, it is the normal thing to do when it cannot do as requested. API changes are not allowed in 2.7 and this one would be dubious even in a future 3.x.

I do think the doc should be more informative and that

Return(s) the fileno of the underlying socket.

should be extended to indicate the specific exception raised when that is not possible.

Return the fileno of the underlying socket if there is one or raise AttributeError.

This should also be added as a docstring (currently missing).

The above is also true for 3.x as self.fp continues to be replaced with None on closing.

The HTTPResponse docs are known to be deficient. #3430

--
I do not think select needs to be changed to understand the HTTPResponse.fileno error indicator because it does not call that method. As indicated in the traceback, it calls (in 2.7) socket._fileinput.fileno. I believe it is only a bug in nappstore (that would be harder to reproduce in 3.x) that _fileinput.fileno is forwarded to HTTPResponse.fileno instead of _socket.fileno. The latter seem to be the clear intention. Even if I am wrong, changing something in the select or socket modules would be a different issue from changing something in the client module.
History
Date User Action Args
2013-10-07 20:13:31terry.reedysetrecipients: + terry.reedy, r.david.murray, docs@python, fviard
2013-10-07 20:13:31terry.reedysetmessageid: <1381176811.46.0.758787673744.issue19154@psf.upfronthosting.co.za>
2013-10-07 20:13:31terry.reedylinkissue19154 messages
2013-10-07 20:13:31terry.reedycreate