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.
This commit is contained in:
Victor Stinner 2023-08-23 07:26:01 +02:00 committed by GitHub
parent 9173b2bbe1
commit 64f9935035
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1021,7 +1021,11 @@ class SSLSocket(socket):
self.close()
except OSError:
pass
try:
raise notconn_pre_handshake_data_error
finally:
# Explicitly break the reference cycle.
notconn_pre_handshake_data_error = None
else:
connected = True