]> granicus.if.org Git - python/commitdiff
bpo-31234, socket.create_connection(): Fix ref cycle (#3546)
authorVictor Stinner <victor.stinner@gmail.com>
Wed, 13 Sep 2017 17:10:10 +0000 (10:10 -0700)
committerGitHub <noreply@github.com>
Wed, 13 Sep 2017 17:10:10 +0000 (10:10 -0700)
Lib/socket.py
Misc/NEWS.d/next/Library/2017-09-13-18-05-56.bpo-31234.lGkcPg.rst [new file with mode: 0644]

index 740e71782af2c32ba792caeb58ffd08911b987cb..1ada24d332642259e17331ae4543314c0dfe03fe 100644 (file)
@@ -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 (file)
index 0000000..e522e8e
--- /dev/null
@@ -0,0 +1,2 @@
+socket.create_connection() now fixes manually a reference cycle: clear the
+variable storing the last exception on success.