From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Wed, 13 Sep 2017 22:54:34 +0000 (-0700) Subject: [3.6] bpo-31234, socket.create_connection(): Fix ref cycle (GH-3546) (#3552) X-Git-Tag: v3.6.3rc1~26 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d99e85b9f6422dd5e4f2eb1539368fc4003d4c8b;p=python [3.6] bpo-31234, socket.create_connection(): Fix ref cycle (GH-3546) (#3552) (cherry picked from commit acb9fa79fa6453c2bbe3ccfc9cad2837feb90093) --- diff --git a/Lib/socket.py b/Lib/socket.py index 740e71782a..1ada24d332 100644 --- a/Lib/socket.py +++ b/Lib/socket.py @@ -711,6 +711,8 @@ def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, if source_address: sock.bind(source_address) sock.connect(sa) + # Break explicitly a reference cycle + err = None return sock except error as _: diff --git a/Misc/NEWS.d/next/Library/2017-09-13-18-05-56.bpo-31234.lGkcPg.rst b/Misc/NEWS.d/next/Library/2017-09-13-18-05-56.bpo-31234.lGkcPg.rst new file mode 100644 index 0000000000..e522e8e952 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2017-09-13-18-05-56.bpo-31234.lGkcPg.rst @@ -0,0 +1,2 @@ +socket.create_connection() now fixes manually a reference cycle: clear the +variable storing the last exception on success.