Skip to content

Commit b8058b3

Browse files
[3.9] gh-108342: Break ref cycle in SSLSocket._create() exc (GH-108344) (#108351)
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 <[email protected]>
1 parent d31ae21 commit b8058b3

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
@@ -1049,7 +1049,11 @@ def _create(cls, sock, server_side=False, do_handshake_on_connect=True,
10491049
self.close()
10501050
except OSError:
10511051
pass
1052-
raise notconn_pre_handshake_data_error
1052+
try:
1053+
raise notconn_pre_handshake_data_error
1054+
finally:
1055+
# Explicitly break the reference cycle.
1056+
notconn_pre_handshake_data_error = None
10531057
else:
10541058
connected = True
10551059

0 commit comments

Comments
 (0)