Commit c18f69e4 authored by Jérome Perrin's avatar Jérome Perrin Committed by Cédric Le Ninivin

Utils/pylint: don't change sys.stdout/stderr

This solves the race condition that leaves stdout as a StringIO when
this is executed twice in parrallel ( #20180928-1D89375 )

But this prints
  No config file found, using default configuration
on sys.stderr at every execution, but that's acceptable.

Once we update pylint, we can disable this warning by setting
verbose=false ( this is not yet available on pylint 1.4.4 )

/reviewed-on nexedi/erp5!758
parent e03ed780
......@@ -463,14 +463,7 @@ def checkPythonSourceCode(source_code_str, portal_type=None):
#started = time.time()
message_list = []
output_file = cStringIO.StringIO()
# pylint prints directly on stderr/stdout (only reporter content matters)
stderr = sys.stderr
stdout = sys.stdout
try:
sys.stderr = cStringIO.StringIO()
sys.stdout = cStringIO.StringIO()
with tempfile.NamedTemporaryFile(suffix='.py') as input_file:
input_file.write(source_code_str)
input_file.flush()
......@@ -535,11 +528,8 @@ def checkPythonSourceCode(source_code_str, portal_type=None):
'row': int(match_obj.group('row')),
'column': int(match_obj.group('column')),
'text': match_obj.group('message')})
finally:
output_file.close()
sys.stderr = stderr
sys.stdout = stdout
#LOG('Utils', INFO, 'Checking time (pylint): %.2f' % (time.time() - started))
return message_list
......
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