From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Wed, 23 Aug 2023 10:10:49 +0000 (-0700) Subject: [3.9] gh-108342: Break ref cycle in SSLSocket._create() exc (GH-108344) (#108351) X-Git-Tag: archive/raspbian/3.9.2-1+rpi1+deb11u2^2~14 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=dcd5f635de1e9e8599d3b6f365b366b86beab85b;p=python3.9.git [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 64f99350351bc46e016b2286f36ba7cd669b79e3) Co-authored-by: Victor Stinner Gbp-Pq: Name 0017-3.9-gh-108342-Break-ref-cycle-in-SSLSocket._create-e.patch --- diff --git a/Lib/ssl.py b/Lib/ssl.py index 2565e7f..3270d9a 100644 --- a/Lib/ssl.py +++ b/Lib/ssl.py @@ -1048,7 +1048,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