Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
diffoscope
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Reproducible Builds
diffoscope
Commits
90028d41
Verified
Commit
90028d41
authored
6 years ago
by
Mattia Rizzolo
Browse files
Options
Downloads
Patches
Plain Diff
comparators: do not shadow the original import errors
Fixes: MR:
!7
Signed-off-by:
Mattia Rizzolo
<
mattia@debian.org
>
parent
fd6eff94
No related branches found
No related tags found
No related merge requests found
Pipeline
#12686
failed
6 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
diffoscope/comparators/__init__.py
+15
-3
15 additions, 3 deletions
diffoscope/comparators/__init__.py
with
15 additions
and
3 deletions
diffoscope/comparators/__init__.py
+
15
−
3
View file @
90028d41
...
...
@@ -19,8 +19,13 @@
# You should have received a copy of the GNU General Public License
# along with diffoscope. If not, see <https://www.gnu.org/licenses/>.
import
sys
import
logging
import
importlib
import
traceback
from
..logging
import
line_ereser
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -108,6 +113,7 @@ class ComparatorManager(object):
self
.
classes
=
[]
for
xs
in
self
.
COMPARATORS
:
errors
=
[]
for
x
in
xs
:
package
,
klass_name
=
x
.
rsplit
(
'
.
'
,
1
)
...
...
@@ -115,16 +121,22 @@ class ComparatorManager(object):
mod
=
importlib
.
import_module
(
'
diffoscope.comparators.{}
'
.
format
(
package
)
)
except
ImportError
:
except
ImportError
as
e
:
errors
.
append
((
x
,
e
))
continue
self
.
classes
.
append
(
getattr
(
mod
,
klass_name
))
break
else
:
# noqa
raise
ImportE
rror
(
"
Could not import {}{}
"
.
format
(
"
any of
"
if
len
(
xs
)
>
1
else
''
,
logger
.
e
rror
(
"
Could not import {}{}
"
.
format
(
"
any of
"
if
len
(
xs
)
>
1
else
''
,
'
,
'
.
join
(
xs
)
))
for
x
in
errors
:
logger
.
error
(
"
Original error for %s:
"
,
x
[
0
])
sys
.
stderr
.
buffer
.
write
(
line_ereser
())
traceback
.
print_exception
(
None
,
x
[
1
],
x
[
1
].
__traceback__
)
sys
.
exit
(
2
)
logger
.
debug
(
"
Loaded %d comparator classes
"
,
len
(
self
.
classes
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment