Skip to content

Commit

Permalink
[3.8] gh-108342: Break ref cycle in SSLSocket._create() exc (GH-108344)…
Browse files Browse the repository at this point in the history
… (#108352)

Explicitly break a reference cycle when SSLSocket._create() raises an
exception. Clear the variable storing the exception, since the
exception traceback contains the variables and so creates a reference
cycle.

This test leak was introduced by the test added for the fix of GH-108310.
(cherry picked from commit 64f9935)

Co-authored-by: Victor Stinner <vstinner@python.org>
  • Loading branch information
miss-islington and vstinner committed Aug 23, 2023
1 parent b4368b5 commit 6f2b64f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Lib/ssl.py
Expand Up @@ -1048,7 +1048,11 @@ def _create(cls, sock, server_side=False, do_handshake_on_connect=True,
self.close()
except OSError:
pass
raise notconn_pre_handshake_data_error
try:
raise notconn_pre_handshake_data_error
finally:
# Explicitly break the reference cycle.
notconn_pre_handshake_data_error = None
else:
connected = True

Expand Down

0 comments on commit 6f2b64f

Please sign in to comment.