Commit eff0c49e 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 5c213180
...@@ -81,16 +81,8 @@ def checkComponent(component_instance): ...@@ -81,16 +81,8 @@ def checkComponent(component_instance):
code = component_instance.getTextContent() code = component_instance.getTextContent()
if six.PY2: if six.PY2:
code = unicode(code, 'utf8') code = unicode(code, 'utf8')
data = {'code': code} for annotation in json.loads(portal.ERP5Site_checkPythonSourceCodeAsJSON(
try: {'code': code}))['annotations']:
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 annotation['component_path'] = component_relative_url
line_list.append( line_list.append(
Message( Message(
......
...@@ -372,6 +372,15 @@ else: ...@@ -372,6 +372,15 @@ else:
return m return m
MANAGER.register_transform(Module, wendelin_transform, lambda node: node.name == 'wendelin') 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 # 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 # 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 # Products.ZSQLMethods; Shared and Shared.DC being a namespace package defined
......
...@@ -2299,6 +2299,13 @@ lxml.etree.Element('test') ...@@ -2299,6 +2299,13 @@ lxml.etree.Element('test')
from BTrees.OOBTree import OOBTree from BTrees.OOBTree import OOBTree
OOBTree() OOBTree()
from cryptography.hazmat.primitives.asymmetric import rsa
rsa.generate_private_key(
public_exponent=65537,
key_size=2048,
).public_key()
""" % (dict(namespace=namespace, """ % (dict(namespace=namespace,
reference1=imported_reference1, reference1=imported_reference1,
module2=imported_module2, module2=imported_module2,
......
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