Skip to content

test_ssl raises ResourceWarning (again) #110011

Open

Description

@sobolevn

Bug report

One:

» ./python.exe -m test test_ssl -m test_preauth_data_to_tls_client
0:00:00 load avg: 1.42 Run 1 test sequentially
0:00:00 load avg: 1.42 [1/1] test_ssl
/Users/sobolev/Desktop/cpython/Lib/test/test_ssl.py:4862: ResourceWarning: unclosed <ssl.SSLSocket fd=8, family=2, type=1, proto=0, laddr=('127.0.0.1', 55685)>
  wrap_error = None
ResourceWarning: Enable tracemalloc to get the object allocation traceback

== Tests result: SUCCESS ==

1 test OK.

Total duration: 137 ms
Total tests: run=1 (filtered) skipped=1
Total test files: run=1/1 (filtered)
Result: SUCCESS

Two:

» ./python.exe -m test test_ssl -m test_preauth_data_to_tls_server
0:00:00 load avg: 1.53 Run 1 test sequentially
0:00:00 load avg: 1.53 [1/1] test_ssl
/Users/sobolev/Desktop/cpython/Lib/test/test_ssl.py:4801: ResourceWarning: unclosed <ssl.SSLSocket fd=9, family=2, type=1, proto=0, laddr=('127.0.0.1', 55718)>
  wrap_error = None
ResourceWarning: Enable tracemalloc to get the object allocation traceback

== Tests result: SUCCESS ==

1 test OK.

Total duration: 121 ms
Total tests: run=1 (filtered) skipped=1
Total test files: run=1/1 (filtered)
Result: SUCCESS

Three:

» ./python.exe -m test test_ssl -m test_https_client_non_tls_response_ignored    
0:00:00 load avg: 1.65 Run 1 test sequentially
0:00:00 load avg: 1.65 [1/1] test_ssl
/Users/sobolev/Desktop/cpython/Lib/traceback.py:244: ResourceWarning: unclosed <ssl.SSLSocket fd=8, family=2, type=1, proto=0, laddr=('127.0.0.1', 56190)>
  tb.tb_frame.clear()
ResourceWarning: Enable tracemalloc to get the object allocation traceback

== Tests result: SUCCESS ==

1 test OK.

Total duration: 80 ms
Total tests: run=1 (filtered)
Total test files: run=1/1 (filtered)
Result: SUCCESS

Env:

  • macos sonoma
  • main branch
test_ssl: testing with 'OpenSSL 3.1.2 1 Aug 2023' (3, 1, 0, 2, 0)
          under Mac ('14.0', ('', '', ''), 'arm64')
          HAS_SNI = True
          OP_ALL = 0x80000050
          OP_NO_TLSv1_1 = 0x10000000

Refs:

Activity

  1. iamsharduld commented on Sep 8, 2026

    @iamsharduld
    Contributor

    The ResourceWarning from test_https_client_non_tls_response_ignored (the third case here) has a cause in http.client: HTTPConnection.connect() leaves self.sock open when setsockopt(TCP_NODELAY) fails, and on macOS that call raises EINVAL once the peer has reset the connection, which is what that test's server does. Reported with details as gh-157174, fix in #157175. The two preauth cases leak an SSLSocket and look like a different path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    testsTests in the Lib/test dirtopic-SSLtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions