From b64334cb93d0ddbb551c8cd712942bab2fc72772 Mon Sep 17 00:00:00 2001 From: Mario Corchero Date: Fri, 6 Dec 2019 14:27:38 +0000 Subject: 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 --- Lib/codeop.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'Lib/codeop.py') diff --git a/Lib/codeop.py b/Lib/codeop.py index fc7e1e70ce..082285f94f 100644 --- a/Lib/codeop.py +++ b/Lib/codeop.py @@ -93,10 +93,13 @@ def _maybe_compile(compiler, source, filename, symbol): except SyntaxError as e: err2 = e - if code: - return code - if not code1 and repr(err1) == repr(err2): - raise err1 + try: + if code: + return code + if not code1 and repr(err1) == repr(err2): + raise err1 + finally: + err1 = err2 = None def _compile(source, filename, symbol): return compile(source, filename, symbol, PyCF_DONT_IMPLY_DEDENT) -- cgit v1.2.1