Commit 9d10f75b authored by Jérome Perrin's avatar Jérome Perrin

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