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 mcjeff
Recipients brett.cannon, mcjeff
Date 2011-03-17.05:48:05
SpamBayes Score 6.3199036e-07
Marked as misclassified No
Message-id <1300340886.14.0.810009018672.issue11563@psf.upfronthosting.co.za>
In-reply-to
Content
So, I've been meaning to get more into contributing back to Python and I found this one somewhat interesting.

As it turns out, even the following simple script raises the same warning:


[jeff@martian cpython]$ ./python -c 'import urllib.request; urllib.request.urlretrieve("http://www.python.org")'
/home/jeff/cpython/Lib/socket.py:340: ResourceWarning: unclosed <socket.socket object, fd=3, family=2, type=1, proto=6>
  self._sock = None
[64388 refs]
[jeff@martian cpython]$ 

The close method of Socket.SocketIO simply sets the underlying socket object to None, which causes that warning.  Explicitly calling the close method on the underlying socket clears that up (and it's protected by that reference counter).

The _decref_socketios just drops the internal ref count and never actually closes -- it won't unless self.__closed is True. 

So, when self._sock is set to None, that error bubbles up. As SocketIO is the foundation used in socket.makefile, I think just adding that close call ought to be correct.

I can do the simple patch if you agree.
History
Date User Action Args
2011-03-17 05:48:06mcjeffsetrecipients: + mcjeff, brett.cannon
2011-03-17 05:48:06mcjeffsetmessageid: <1300340886.14.0.810009018672.issue11563@psf.upfronthosting.co.za>
2011-03-17 05:48:05mcjefflinkissue11563 messages
2011-03-17 05:48:05mcjeffcreate