# HG changeset patch # User Brett Cannon # Date 1257383842 0 # Node ID d3a81051663b6b56b8cdc74ec422020b02d9b4dd # Parent f89a93a778a81d068dc89261d4e7fa22c9bd5811 importlib.test.source.util referenced variables in the 'finally' part of a try/finally which may not have been set. diff -r f89a93a778a8 -r d3a81051663b Lib/importlib/test/source/util.py --- a/Lib/importlib/test/source/util.py Wed Nov 04 21:10:38 2009 +0000 +++ b/Lib/importlib/test/source/util.py Thu Nov 05 01:17:22 2009 +0000 @@ -55,6 +55,8 @@ source = 'attr = {0!r}' created_paths = [] mapping = {} + state_manager = None + uncache_manager = None try: temp_dir = tempfile.gettempdir() mapping['.root'] = temp_dir @@ -85,8 +87,10 @@ state_manager.__enter__() yield mapping finally: - state_manager.__exit__(None, None, None) - uncache_manager.__exit__(None, None, None) + if state_manager is not None: + state_manager.__exit__(None, None, None) + if uncache_manager is not None: + uncache_manager.__exit__(None, None, None) # Reverse the order for path removal to unroll directory creation. for path in reversed(created_paths): if file_path.endswith('.py'): diff -r f89a93a778a8 -r d3a81051663b Misc/NEWS --- a/Misc/NEWS Wed Nov 04 21:10:38 2009 +0000 +++ b/Misc/NEWS Thu Nov 05 01:17:22 2009 +0000 @@ -354,6 +354,10 @@ Tests ----- +- Issue #7248: In importlib.test.source.util a try/finally block did not make + sure that some referenced objects actually were created in the block before + calling methods on the object. + - Issue #7222: Make thread "reaping" more reliable so that reference leak-chasing test runs give sensible results. The previous method of reaping threads could return successfully while some Thread objects were