[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.


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=('', 60379), raddr=('', 443)>

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>

More information about the New-bugs-announce mailing list