Skip to content

Commit d99e85b

Browse files
miss-islingtonvstinner
authored andcommitted
[3.6] bpo-31234, socket.create_connection(): Fix ref cycle (GH-3546) (#3552)
(cherry picked from commit acb9fa7)
1 parent 769ddb0 commit d99e85b

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

Lib/socket.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,8 @@ def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT,
711711
if source_address:
712712
sock.bind(source_address)
713713
sock.connect(sa)
714+
# Break explicitly a reference cycle
715+
err = None
714716
return sock
715717

716718
except error as _:
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
socket.create_connection() now fixes manually a reference cycle: clear the
2+
variable storing the last exception on success.

0 commit comments

Comments
 (0)