Message81651
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) |
|
Date |
User |
Action |
Args |
2009-02-11 16:56:56 | ajaksu2 | set | recipients:
+ ajaksu2, brett.cannon, georg.brandl, kevindication |
2009-02-11 16:56:56 | ajaksu2 | set | messageid: <1234371416.07.0.912735773345.issue1327971@psf.upfronthosting.co.za> |
2009-02-11 16:56:54 | ajaksu2 | link | issue1327971 messages |
2009-02-11 16:56:53 | ajaksu2 | create | |
|