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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Sebastien Robin
erp5
Commits
ec21a348
Commit
ec21a348
authored
Apr 27, 2022
by
Arnaud Fontaine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
py3: ZODB Components: New Exception ModuleNotFoundError which avoids a hack in Python2.
parent
12e8b5ba
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
1 deletion
+10
-1
product/ERP5Type/dynamic/component_package.py
product/ERP5Type/dynamic/component_package.py
+10
-1
No files found.
product/ERP5Type/dynamic/component_package.py
View file @
ec21a348
...
@@ -30,6 +30,7 @@
...
@@ -30,6 +30,7 @@
# There is absolutely no reason to use relative imports when loading a Component
# There is absolutely no reason to use relative imports when loading a Component
from
__future__
import
absolute_import
from
__future__
import
absolute_import
import
six
import
sys
import
sys
import
imp
import
imp
import
collections
import
collections
...
@@ -51,6 +52,12 @@ class ComponentVersionPackage(ModuleType):
...
@@ -51,6 +52,12 @@ class ComponentVersionPackage(ModuleType):
"""
"""
__path__
=
[]
__path__
=
[]
try
:
ModuleNotFoundError
except
NameError
:
# < 3.6
class
ModuleNotFoundError
(
ImportError
):
pass
class
ComponentDynamicPackage
(
ModuleType
):
class
ComponentDynamicPackage
(
ModuleType
):
"""
"""
A top-level component is a package as it contains modules, this is required
A top-level component is a package as it contains modules, this is required
...
@@ -420,8 +427,10 @@ class ComponentDynamicPackage(ModuleType):
...
@@ -420,8 +427,10 @@ class ComponentDynamicPackage(ModuleType):
# load_module(), and returning module 'name' in contrary to __import__
# load_module(), and returning module 'name' in contrary to __import__
# returning 'erp5' (requiring fromlist parameter which is slower)
# returning 'erp5' (requiring fromlist parameter which is slower)
return
import_module
(
fullname
)
return
import_module
(
fullname
)
except
ModuleNotFoundError
:
pass
except
ImportError
as
e
:
except
ImportError
as
e
:
if
str
(
e
)
!=
"No module named "
+
name
:
if
s
ix
.
PY3
or
s
tr
(
e
)
!=
"No module named "
+
name
:
LOG
(
"ERP5Type.dynamic"
,
WARNING
,
LOG
(
"ERP5Type.dynamic"
,
WARNING
,
"Could not load Component module %r"
%
fullname
,
error
=
True
)
"Could not load Component module %r"
%
fullname
,
error
=
True
)
...
...
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