[issue26620] Fix ResourceWarning warnings in test_urllib2_localnet

STINNER Victor report at bugs.python.org
Thu Mar 24 09:20:46 EDT 2016


STINNER Victor added the comment:

Martin wrote:
> This patch looks okay to me. I left one review suggestion.

Thanks for the review, I changed this code.

While testing one more time my patch with CTRL+c, I noticed that sometimes the servers are not stopped properly and os.environ is not restored.

I made some extra changes to try to restore os.environ and try to close the server in more cases.

It's not perfect. Since unittest.TestCase.doCleanups() doesn't handle KeyboardInterrupt, there is no warranty that cleanup functions are always executed.

> Focussing on test_sending_headers(), the ResourceWarning seems to be only shown since revision 46329eec5515 (Issue 26590). In simpler cases, the warning would be bypassed due to Issue 19829. But in this cases it seems there is a garbage cycle which may be involved in the new warning.

It's possible that Python 3.5 failed to log ResourceWarning in some cases, Python 3.6 should be better on this part.

----------

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


More information about the Python-bugs-list mailing list