Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
erp5
Commits
7aa6dd2b
Commit
7aa6dd2b
authored
Nov 10, 2022
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Plain Diff
Fix astroid KeyError _CONST_PROXY
See merge request
nexedi/erp5!1683
parents
5bfb680a
b1d6fae6
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
10 deletions
+48
-10
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BusinessTemplate_getPythonSourceCodeMessageList.py
...5_core/BusinessTemplate_getPythonSourceCodeMessageList.py
+2
-10
product/ERP5Type/patches/pylint.py
product/ERP5Type/patches/pylint.py
+19
-0
product/ERP5Type/tests/testDynamicClassGeneration.py
product/ERP5Type/tests/testDynamicClassGeneration.py
+27
-0
No files found.
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BusinessTemplate_getPythonSourceCodeMessageList.py
View file @
7aa6dd2b
...
...
@@ -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
(
...
...
product/ERP5Type/patches/pylint.py
View file @
7aa6dd2b
...
...
@@ -372,6 +372,25 @@ 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
)
try
:
import
xmlsec
except
ImportError
:
pass
else
:
_register_module_extender_from_live_module
(
'xmlsec'
,
xmlsec
)
_register_module_extender_from_live_module
(
'xmlsec.tree'
,
xmlsec
.
tree
)
_register_module_extender_from_live_module
(
'xmlsec.template'
,
xmlsec
.
template
)
# 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
...
...
product/ERP5Type/tests/testDynamicClassGeneration.py
View file @
7aa6dd2b
...
...
@@ -2285,12 +2285,39 @@ class FooBar(ValidationFailed):
def __init__(self, *args, **kw):
super(FooBar, self).__init__(*args, **kw)
# Test for various pylint fixes
# Transforms for Zope which should ideally be upstream'ed
from AccessControl.PermissionRole import rolesForPermissionOn, PermissionRole, imPermissionRole, _what_not_even_god_should_do # pylint: disable=unused-import
# Monkey patch of astroid 1.3.8: it raised 'no-name-in-module' because
# Shared.DC was not considered a namespace package
from Shared.DC.ZRDB.Results import Results # pylint: disable=unused-import
import lxml.etree
lxml.etree.Element('test')
from BTrees.OOBTree import OOBTree
OOBTree()
from cryptography.hazmat.primitives.asymmetric import rsa
rsa.generate_private_key(
public_exponent=65537,
key_size=2048,
).public_key()
def xmlsec_decrypt():
# from https://xmlsec.readthedocs.io/en/stable/examples.html#decrypt
import xmlsec
manager = xmlsec.KeysManager()
key = xmlsec.Key.from_file('rsakey.pem', xmlsec.constants.KeyDataFormatPem)
manager.add_key(key)
enc_ctx = xmlsec.EncryptionContext(manager)
root = lxml.etree.parse("enc1-res.xml").getroot()
enc_data = xmlsec.tree.find_child(root, "EncryptedData", xmlsec.constants.EncNs)
decrypted = enc_ctx.decrypt(enc_data)
print(lxml.etree.tostring(decrypted))
"""
%
(
dict
(
namespace
=
namespace
,
reference1
=
imported_reference1
,
module2
=
imported_module2
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment