[3.6] bpo-31234, socket.create_connection(): Fix ref cycle (GH-3546) (#3552)

(cherry picked from commit acb9fa79fa)
This commit is contained in:
Miss Islington (bot) 2017-09-13 15:54:34 -07:00 committed by Victor Stinner
parent 769ddb075a
commit d99e85b9f6
2 changed files with 4 additions and 0 deletions

View 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 _:

View file

@ -0,0 +1,2 @@
socket.create_connection() now fixes manually a reference cycle: clear the
variable storing the last exception on success.