Original file line numberDiff line numberDiff line change@@ -93,10 +93,13 @@ def _maybe_compile(compiler, source, filename, symbol):
9393exceptSyntaxErrorase:
9494err2=e
959596-ifcode:
97-returncode
98-ifnotcode1andrepr(err1) ==repr(err2):
99-raiseerr1
96+try:
97+ifcode:
98+returncode
99+ifnotcode1andrepr(err1) ==repr(err2):
100+raiseerr1
101+finally:
102+err1=err2=None
100103101104def_compile(source, filename, symbol):
102105returncompile(source, filename, symbol, PyCF_DONT_IMPLY_DEDENT)
Original file line numberDiff line numberDiff line change@@ -149,6 +149,8 @@ def framework_find(fn, executable_path=None, env=None):
149149returndyld_find(fn, executable_path=executable_path, env=env)
150150exceptValueError:
151151raiseerror
152+finally:
153+error=None
152154153155deftest_dyld_find():
154156env= {}
Original file line numberDiff line numberDiff line change@@ -839,7 +839,11 @@ def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT,
839839sock.close()
840840841841iferrisnotNone:
842-raiseerr
842+try:
843+raiseerr
844+finally:
845+# Break explicitly a reference cycle
846+err=None
843847else:
844848raiseerror("getaddrinfo returns an empty list")
845849Original file line numberDiff line numberDiff line change@@ -0,0 +1,3 @@
1+Break cycle generated when saving an exception in socket.py, codeop.py and
2+dyld.py as they keep alive not only the exception but user objects through
3+the ``__traceback__`` attribute. Patch by Mario Corchero.