Skip to content

Commit 64f9935

Browse files
authored
gh-108342: Break ref cycle in SSLSocket._create() exc (#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 #108310.
1 parent 9173b2b commit 64f9935

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Lib/ssl.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,11 @@ def _create(cls, sock, server_side=False, do_handshake_on_connect=True,
10211021
self.close()
10221022
except OSError:
10231023
pass
1024-
raise notconn_pre_handshake_data_error
1024+
try:
1025+
raise notconn_pre_handshake_data_error
1026+
finally:
1027+
# Explicitly break the reference cycle.
1028+
notconn_pre_handshake_data_error = None
10251029
else:
10261030
connected = True
10271031

0 commit comments

Comments
 (0)