[3.6] bpo-31234, socket.create_connection(): Fix ref cycle (GH-3546) … · python/cpython@d99e85b (original) (raw)
2 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -711,6 +711,8 @@ def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, | ||
711 | 711 | if source_address: |
712 | 712 | sock.bind(source_address) |
713 | 713 | sock.connect(sa) |
714 | +# Break explicitly a reference cycle | |
715 | +err = None | |
714 | 716 | return sock |
715 | 717 | |
716 | 718 | except error as _: |
Original file line number | Diff line number | Diff 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. |