Commit 969c3e23 authored by Arnaud Fontaine's avatar Arnaud Fontaine

ZODB Components: checkPythonSourceCode(): AST object of temp file was never GC'ed.

parent 1cb2dc4c
...@@ -468,7 +468,8 @@ def checkPythonSourceCode(source_code_str, portal_type=None): ...@@ -468,7 +468,8 @@ def checkPythonSourceCode(source_code_str, portal_type=None):
message_list = [] message_list = []
output_file = cStringIO.StringIO() output_file = cStringIO.StringIO()
try: try:
with tempfile.NamedTemporaryFile(suffix='.py') as input_file: with tempfile.NamedTemporaryFile(prefix='checkPythonSourceCode',
suffix='.py') as input_file:
input_file.write(source_code_str) input_file.write(source_code_str)
input_file.flush() input_file.flush()
...@@ -522,7 +523,13 @@ def checkPythonSourceCode(source_code_str, portal_type=None): ...@@ -522,7 +523,13 @@ def checkPythonSourceCode(source_code_str, portal_type=None):
args.append('--load-plugins=' + ext) args.append('--load-plugins=' + ext)
except ImportError: except ImportError:
pass pass
Run(args, reporter=TextReporter(output_file), exit=False) try:
Run(args, reporter=TextReporter(output_file), exit=False)
finally:
from astroid.builder import MANAGER
MANAGER.astroid_cache.pop(
os.path.splitext(os.path.basename(input_file.name))[0],
None)
output_file.reset() output_file.reset()
for line in output_file: for line in output_file:
......
...@@ -2149,7 +2149,8 @@ def function_foo(*args, **kwargs): ...@@ -2149,7 +2149,8 @@ def function_foo(*args, **kwargs):
from astroid.builder import MANAGER from astroid.builder import MANAGER
should_not_be_in_cache_list = [] should_not_be_in_cache_list = []
for modname in MANAGER.astroid_cache: for modname in MANAGER.astroid_cache:
if modname in must_not_be_in_cache_set: if (modname.startswith('checkPythonSourceCode') or
modname in must_not_be_in_cache_set):
should_not_be_in_cache_list.append(modname) should_not_be_in_cache_list.append(modname)
if modname in must_be_in_cache_set: if modname in must_be_in_cache_set:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment