Commit 291769cd authored by Jérome Perrin's avatar Jérome Perrin

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

backport nexedi/erp5!758

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 https://lab.nexedi.com/nexedi/erp5-capago/merge_requests/43
parent 89bba3e3
......@@ -463,14 +463,7 @@ def checkPythonSourceCode(source_code_str):
#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.seek(0)
......@@ -521,11 +514,8 @@ def checkPythonSourceCode(source_code_str):
'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