[Reproducible-commits] [diffoscope] 06/09: Add compatibility with Python 3 when looking at ImportError

Jérémy Bobbio lunar at moszumanska.debian.org
Fri Sep 18 10:54:40 UTC 2015


This is an automated email from the git hooks/post-receive script.

lunar pushed a commit to branch master
in repository diffoscope.

commit 2c3c4a8d50876bcb01020eef18ea625bb0841204
Author: Jérémy Bobbio <lunar at debian.org>
Date:   Fri Sep 18 12:16:27 2015 +0200

    Add compatibility with Python 3 when looking at ImportError
    
    In Python 3, the message is in the 'msg' attribute instead of 'message'.
---
 diffoscope/comparators/__init__.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/diffoscope/comparators/__init__.py b/diffoscope/comparators/__init__.py
index 8fe3da5..0900a37 100644
--- a/diffoscope/comparators/__init__.py
+++ b/diffoscope/comparators/__init__.py
@@ -49,7 +49,9 @@ from diffoscope.comparators.png import PngFile
 try:
     from diffoscope.comparators.rpm import RpmFile
 except ImportError as ex:
-    if ex.message != 'No module named rpm':
+    if hasattr(ex, 'message') and ex.message != 'No module named rpm': # Python 2
+        raise
+    if hasattr(ex, 'msg') and ex.msg != "No module named 'rpm'": # Python 3
         raise
     from diffoscope.comparators.rpm_fallback import RpmFile
 from diffoscope.comparators.sqlite import Sqlite3Database

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git



More information about the Reproducible-commits mailing list