[issue10883] urllib: socket is not closed explicitly

STINNER Victor report at bugs.python.org
Fri Jun 17 15:01:43 CEST 2011


STINNER Victor <victor.stinner at haypocalc.com> added the comment:

ftp_close.patch:
 - (in passive mode) FTP.ntransfercmd() closes explicitly the socket on error: the caller has not access to the socket on error
 - OtherNetworkTests of test_urllib2net clears CacheFTPHandler cache: add a CacheFTPHandler.clear_cache() for that (I didn't document this new method because other methods are also not documented)
 - the last change is the worst one (ugly hack): FTPHandler.ftp_open() changes the close callback of the addclosehook object in ftpwrapper.retrfile(), but not in CacheFTPHandler.

I don't like the implementation of the last change:
 - it adds a protected class attribute
 - ftpwrapper.retrfile() requires an explicit close=True argument: it would be better to use a "reference counter" (or something like that), like socket._io_refs

----------
keywords: +patch
Added file: http://bugs.python.org/file22392/ftp_close.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10883>
_______________________________________


More information about the Python-bugs-list mailing list