Skip to content

Commit 8e55056

Browse files
vstinnermiss-islington
authored andcommitted
pythongh-108342: Break ref cycle in SSLSocket._create() exc (pythonGH-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]>
1 parent 1aff195 commit 8e55056

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Lib/ssl.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,11 @@ def _create(cls, sock, server_side=False, do_handshake_on_connect=True,
10831083
self.close()
10841084
except OSError:
10851085
pass
1086-
raise notconn_pre_handshake_data_error
1086+
try:
1087+
raise notconn_pre_handshake_data_error
1088+
finally:
1089+
# Explicitly break the reference cycle.
1090+
notconn_pre_handshake_data_error = None
10871091
else:
10881092
connected = True
10891093

0 commit comments

Comments
 (0)