Commit 3fb5a784 authored by Jérome Perrin's avatar Jérome Perrin

patches/pylint: teach astroid about cryptography.hazmat.bindings._openssl

This version of pylint tries to import the C modules for analysis and
get confused by support ffi's CompiledFFI type.

Use our utility  _register_module_extender_from_live_module to register
a stub module instead.

This also reverts b21f83fc,
"BusinessTemplate_getPythonSourceCodeMessageList: Retry in case of
pylint internal failure." which is no longer necessary with these
changes.
parent 3e5ca320
......@@ -81,16 +81,8 @@ def checkComponent(component_instance):
code = component_instance.getTextContent()
if six.PY2:
code = unicode(code, 'utf8')
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']:
for annotation in json.loads(portal.ERP5Site_checkPythonSourceCodeAsJSON(
{'code': code}))['annotations']:
annotation['component_path'] = component_relative_url
line_list.append(
Message(
......
......@@ -372,6 +372,15 @@ else:
return m
MANAGER.register_transform(Module, wendelin_transform, lambda node: node.name == 'wendelin')
# prevent a crash with cryptography:
# File "develop-eggs/astroid-1.3.8+slapospatched001-py2.7.egg/astroid/raw_building.py", line 360, in _set_proxied
# return _CONST_PROXY[const.value.__class__]
# KeyError: <type 'CompiledFFI'>
import cryptography.hazmat.bindings._openssl
_register_module_extender_from_live_module(
'cryptography.hazmat.bindings._openssl',
cryptography.hazmat.bindings._openssl)
# Properly search for namespace packages: original astroid (as of 1.3.8) only
# checks at top-level and it doesn't work for Shared.DC.ZRDB (defined in
# Products.ZSQLMethods; Shared and Shared.DC being a namespace package defined
......
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