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

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

parent 1cb2dc4c
Pipeline #6446 passed with stage
in 0 seconds
......@@ -468,7 +468,8 @@ def checkPythonSourceCode(source_code_str, portal_type=None):
message_list = []
output_file = cStringIO.StringIO()
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.flush()
......@@ -522,7 +523,13 @@ def checkPythonSourceCode(source_code_str, portal_type=None):
args.append('--load-plugins=' + ext)
except ImportError:
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()
for line in output_file:
......
......@@ -2149,7 +2149,8 @@ def function_foo(*args, **kwargs):
from astroid.builder import MANAGER
should_not_be_in_cache_list = []
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)
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