[Git][reproducible-builds/diffoscope][master] Also catch RuntimeError when importing PyPDF so that PyPDF or, crucially, its...

Chris Lamb (@lamby) gitlab at salsa.debian.org
Sun Aug 18 17:38:43 UTC 2024



Chris Lamb pushed to branch master at Reproducible Builds / diffoscope


Commits:
c1aa6259 by Chris Lamb at 2024-08-18T18:38:12+01:00
Also catch RuntimeError when importing PyPDF so that PyPDF or, crucially, its transitive dependencies do not cause diffoscope to traceback at runtime and build time. (Closes: Debian:#1078944, reproducible-builds/diffoscope#389)

The root or even primary cause of this bug is not in diffoscope itself; rather,
the cause is to be found between src:python3-cryptography and src:openssl — see
bugs #1078747 and #965041 for more details.

However, diffoscope should (and easily can…) be mindful that importing external
libraries could result in exceptions other than ImportError when we have reason
to believe that they might do so.

We already do so in fsimage.py for a complicated library (guestfs), so I think
it's not at all unreasonable to catch it here, too.

Alas I can't seem to reproduce this on my local machine or in a clean sid
chroot, so I am uploading the following patch after simply having a hard stare
at the code… albeit on a warm Sunday afternoon.

- - - - -


2 changed files:

- diffoscope/comparators/pdf.py
- tests/comparators/test_pdf.py


Changes:

=====================================
diffoscope/comparators/pdf.py
=====================================
@@ -72,7 +72,7 @@ try:
             # PyPDF 1.x
             from PyPDF2.utils import PdfReadError
 
-except ImportError:  # noqa
+except (ImportError, RuntimeError):  # noqa
     python_module_missing("pypdf")
     pypdf = None
 


=====================================
tests/comparators/test_pdf.py
=====================================
@@ -42,7 +42,7 @@ def skip_unless_pypdf3():
     def fn():
         try:
             import pypdf
-        except ImportError:
+        except (ImportError, RuntimeError):
             return True
 
         return not pypdf.__version__.startswith("3.")



View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/commit/c1aa6259cd1954182a02ede393c3540dcda33a11

-- 
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/commit/c1aa6259cd1954182a02ede393c3540dcda33a11
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.reproducible-builds.org/pipermail/rb-commits/attachments/20240818/31de06d7/attachment.htm>


More information about the rb-commits mailing list