Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pythongh-108342: Break ref cycle in SSLSocket._create() exc (pythonGH…
Browse files Browse the repository at this point in the history
…-108344)

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 pythonGH-108310.
(cherry picked from commit 64f9935)

Co-authored-by: Victor Stinner <[email protected]>
vstinner authored and miss-islington committed Aug 23, 2023

Verified

This commit was signed with the committer’s verified signature.
cnasikas Christos Nasikas
1 parent d31ae21 commit 8c57e81
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Lib/ssl.py
Original file line number Diff line number Diff line change
@@ -1049,7 +1049,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

0 comments on commit 8c57e81

Please sign in to comment.