This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ajaksu2
Recipients ajaksu2, brett.cannon, georg.brandl, kdwyer
Date 2009-02-11.16:56:52
SpamBayes Score 9.594668e-07
Marked as misclassified No
Message-id <1234371416.07.0.912735773345.issue1327971@psf.upfronthosting.co.za>
In-reply-to
Content
IMHO, using a fileno property looks better than __getattr__. Setting an
attribute in init works too, unless fp changes during the object life
(then 3.x is broken IIUC).

It works OK as a property of either urllib.addinfourl or of
httplib.HTTPResponse (socket would work, but is this broken there or a
higher layer). 

Tests and fixes for both solutions attached. As soon as one is chosen,
some docs on fileno would be nice, even for 3.x.


This (current) test in test_urllibnet.py passes, but I don't see how to
improve it, assuming it should fail/detect this bug (maybe self.urlopen
isn't testing urllib.urlopen correctly?):

    def test_fileno(self):
        if (sys.platform in ('win32',) or
                not hasattr(os, 'fdopen')):
            # On Windows, socket handles are not file descriptors; this
            # test can't pass on Windows.
            return
        # Make sure fd returned by fileno is valid.
        open_url = self.urlopen("http://www.python.org/")
        fd = open_url.fileno()
        FILE = os.fdopen(fd)
History
Date User Action Args
2009-02-11 16:56:56ajaksu2setrecipients: + ajaksu2, brett.cannon, georg.brandl, kevindication
2009-02-11 16:56:56ajaksu2setmessageid: <1234371416.07.0.912735773345.issue1327971@psf.upfronthosting.co.za>
2009-02-11 16:56:54ajaksu2linkissue1327971 messages
2009-02-11 16:56:53ajaksu2create