bpo-31234, socket.create_connection(): Fix ref cycle (#3546)

This commit is contained in:
Victor Stinner 2017-09-13 10:10:10 -07:00 committed by GitHub
parent b157ce1e58
commit acb9fa79fa
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.