summaryrefslogtreecommitdiffstats
path: root/Lib/ssl.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2023-08-23 05:26:01 (GMT)
committerGitHub <noreply@github.com>2023-08-23 05:26:01 (GMT)
commit64f99350351bc46e016b2286f36ba7cd669b79e3 (patch)
tree14a9d35a1bc9ae688fce5d96adfebb174185d62c /Lib/ssl.py
parent9173b2bbe13aeccc075b571da05c653a2a91de1b (diff)
downloadcpython-64f99350351bc46e016b2286f36ba7cd669b79e3.zip
cpython-64f99350351bc46e016b2286f36ba7cd669b79e3.tar.gz
cpython-64f99350351bc46e016b2286f36ba7cd669b79e3.tar.bz2
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.
Diffstat (limited to 'Lib/ssl.py')
-rw-r--r--Lib/ssl.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/ssl.py b/Lib/ssl.py
index ff363c7..c4c5a4c 100644
--- a/Lib/ssl.py
+++ b/Lib/ssl.py
@@ -1021,7 +1021,11 @@ class SSLSocket(socket):
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