Antoine Pitrou added the comment:

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

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue1208304>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to