Commit b21f83fc authored by Vincent Pelletier's avatar Vincent Pelletier

BusinessTemplate_getPythonSourceCodeMessageList: Retry in case of pylint internal failure.

Pylint, at least our current version (still 1.4.4 as some more recent
versions are apparently much slower), may choke on some imports on the
first validation since Zope was started, only to later succeed. Hypothesis
is that it fails to analyse some imported modules, leaving empty shells
behind in some cache, making a second test avoid the error.
Here is one such error:
  File "eggs/astroid-1.3.8-py2.7.egg/astroid/bases.py", line 86, in cache_generator
    for result in generator:
  File "eggs/astroid-1.3.8-py2.7.egg/astroid/bases.py", line 327, in wrapped
    for res in _func(node, context, **kwargs):
  File "eggs/astroid-1.3.8-py2.7.egg/astroid/bases.py", line 351, in wrapper
    for node in func(*args, **kwargs):
  File "eggs/astroid-1.3.8-py2.7.egg/astroid/inference.py", line 190, in infer_callfunc
    for callee in self.func.infer(context):
  File "eggs/astroid-1.3.8-py2.7.egg/astroid/bases.py", line 86, in cache_generator
    for result in generator:
  File "eggs/astroid-1.3.8-py2.7.egg/astroid/bases.py", line 327, in wrapped
    for res in _func(node, context, **kwargs):
  File "eggs/astroid-1.3.8-py2.7.egg/astroid/bases.py", line 351, in wrapper
    for node in func(*args, **kwargs):
  File "eggs/astroid-1.3.8-py2.7.egg/astroid/inference.py", line 247, in infer_getattr
    for obj in owner.igetattr(self.attrname, context):
  File "eggs/astroid-1.3.8-py2.7.egg/astroid/bases.py", line 187, in igetattr
    context.push((self._proxied, name))
  File "eggs/astroid-1.3.8-py2.7.egg/astroid/raw_building.py", line 360, in _set_proxied
    return _CONST_PROXY[const.value.__class__]
KeyError: <type 'CompiledFFI'>
parent 8990ee68
......@@ -81,8 +81,16 @@ def checkComponent(component_instance):
code = component_instance.getTextContent()
if six.PY2:
code = unicode(code, 'utf8')
for annotation in json.loads(portal.ERP5Site_checkPythonSourceCodeAsJSON(
{'code': code}))['annotations']:
data = {'code': code}
try:
check_result_json = portal.ERP5Site_checkPythonSourceCodeAsJSON(data)
except Exception:
# pylint sometimes raises on the first attempt at importing modules, but
# may succeed on the second try (probably because of incomplete cleanup
# of partially imported moduled). We are not interested in pylint issues,
# we are interested in our code's issues, so give it one more try.
check_result_json = portal.ERP5Site_checkPythonSourceCodeAsJSON(data)
for annotation in json.loads(check_result_json)['annotations']:
annotation['component_path'] = component_relative_url
line_list.append(
Message(
......
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