[New-bugs-announce] [issue26612] test_ssl: use context manager (with) to fix ResourceWarning

STINNER Victor report at bugs.python.org
Tue Mar 22 20:47:46 EDT 2016


New submission from STINNER Victor:

Attached patch modifies Lib/test/test_ssl.py to use "with socket:" instead of "try: ... finally: socket.close()" or similar patterns.

Our PPC64 AIX 3.x buildbot has a broken ssl module. A lot of tests logs ResourceWarning on unclosed sockets, because errors occur before the test closes a socket.

http://buildbot.python.org/all/builders/PPC64%20AIX%203.x/builds/4714/steps/test/logs/stdio

test_connect_ex_error (test.test_ssl.NetworkedTests) ... ok
test_connect_with_context (test.test_ssl.NetworkedTests) ... FAIL
/home/shager/cpython-buildarea/3.x.edelsohn-aix-ppc64/build/Lib/unittest/case.py:628: ResourceWarning: unclosed <ssl.SSLSocket fd=7, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('140.211.15.154', 60379), raddr=('23.253.148.168', 443)>
  outcome.errors.clear()

----------
files: test_ssl_with.patch
keywords: patch
messages: 262222
nosy: haypo
priority: normal
severity: normal
status: open
title: test_ssl: use context manager (with) to fix ResourceWarning
versions: Python 3.6
Added file: http://bugs.python.org/file42245/test_ssl_with.patch

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


More information about the New-bugs-announce mailing list