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 pitrou
Recipients BreamoreBoy, a.badger, akuchling, amaury.forgeotdarc, bwelling, gdub, holdenweb, jafo, jhylton, manekcz, nswinton, orsenthil, peci, pitrou, schmir, stephbul
Date 2013-04-11.12:39:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1365683958.93.0.0641042907783.issue1208304@psf.upfronthosting.co.za>
In-reply-to
Content
I see no file descriptor leak myself:

>>> f = urllib2.urlopen("http://www.google.com")
>>> f.fileno()
3
>>> os.fstat(3)
posix.stat_result(st_mode=49663, st_ino=5045244, st_dev=7L, st_nlink=1, st_uid=1000, st_gid=1000, st_size=0, st_atime=0, st_mtime=0, st_ctime=0)
>>> del f
>>> os.fstat(3)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: [Errno 9] Bad file descriptor

Ditto with Python 3:

>>> f = urllib.request.urlopen("http://www.google.com")
>>> f.fileno()
3
>>> os.fstat(3)
posix.stat_result(st_mode=49663, st_ino=5071469, st_dev=7, st_nlink=1, st_uid=1000, st_gid=1000, st_size=0, st_atime=0, st_mtime=0, st_ctime=0)
>>> del f
>>> os.fstat(3)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: [Errno 9] Bad file descriptor

Furthermore, you can use the `with` statement to ensure timely disposal of system resources:

>>> f = urllib.request.urlopen("http://www.google.com")
>>> with f: f.fileno()
... 
3
>>> os.fstat(3)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: [Errno 9] Bad file descriptor
History
Date User Action Args
2013-04-11 12:39:18pitrousetrecipients: + pitrou, jhylton, akuchling, holdenweb, jafo, amaury.forgeotdarc, orsenthil, bwelling, schmir, stephbul, manekcz, nswinton, a.badger, peci, BreamoreBoy, gdub
2013-04-11 12:39:18pitrousetmessageid: <1365683958.93.0.0641042907783.issue1208304@psf.upfronthosting.co.za>
2013-04-11 12:39:18pitroulinkissue1208304 messages
2013-04-11 12:39:18pitroucreate