summaryrefslogtreecommitdiff
path: root/Lib/socket.py
diff options
context:
space:
mode:
authorMario Corchero <mcorcherojim@bloomberg.net>2019-12-06 14:27:38 +0000
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-12-06 06:27:38 -0800
commitb64334cb93d0ddbb551c8cd712942bab2fc72772 (patch)
tree131741a192a23a07dcd4d7f45aa2a7bd95746238 /Lib/socket.py
parentefefe25443c56988841ab96cdac01352123ba268 (diff)
downloadcpython-git-b64334cb93d0ddbb551c8cd712942bab2fc72772.tar.gz
bpo-36820: Break unnecessary cycle in socket.py, codeop.py and dyld.py (GH-13135)
Break cycle generated when saving an exception in socket.py, codeop.py and dyld.py as they keep alive not only the exception but user objects through the ``__traceback__`` attribute. https://bugs.python.org/issue36820 Automerge-Triggered-By: @pablogsal
Diffstat (limited to 'Lib/socket.py')
-rwxr-xr-xLib/socket.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/socket.py b/Lib/socket.py
index 84a5dcb0da..374f1124bf 100755
--- a/Lib/socket.py
+++ b/Lib/socket.py
@@ -839,7 +839,11 @@ def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT,
sock.close()
if err is not None:
- raise err
+ try:
+ raise err
+ finally:
+ # Break explicitly a reference cycle
+ err = None
else:
raise error("getaddrinfo returns an empty list")