reopen 1146433
found 1146433 python-cliff/4.16.0-3
thanks

Hi!

Sorry to reopen this, but unfortunately the fix applied in the package
is not right :(. Catching MetadataNotFound is only available in Python
3.15+, so now this breaks for packages using Python 3.14.

The patch that was merged upstream is correct [1].

I've applied it in the sandbox to verify that packages that depend on
python-cliff can build successfully, and it does indeed work.

Happy hacking,

[1]: https://review.opendev.org/c/openstack/cliff/+/1003514

--
"Can you imagine what I would do if I could do all I can?" -- Sun Tzu
Saludos /\/\ /\ >< `/
Description: Gracefully handle metadata packages_distributions
 .
 In Python 3.15, importlib.metadata.packages_distributions() raises
 MetadataNotFound if any distribution directory on sys.path has
 missing or incomplete metadata.
 .
 This patch gracefully handle metadata errors in
 packages_distributions.
Author: Maximiliano Curia <[email protected]>
Date: Wed, 02 Sep 2026 13:30:55 +0200
Bug-Debian: https://bugs.debian.org/1146433
Signed-off-by: Thomas Goirand <[email protected]>
Change-Id: Ib1f51b7ea0bb9a63120c53506f7b351a3afb1ba2
Forwarded: https://review.opendev.org/c/openstack/cliff/+/1003514
Last-Update: 2026-09-22

diff --git a/cliff/command.py b/cliff/command.py
index 923cf9b..64d0262 100644
--- a/cliff/command.py
+++ b/cliff/command.py
@@ -42,7 +42,14 @@
     if _dists_by_mods is None:
         # There can be multiple distribution in the case of namespace packages
         # so we'll just grab the first one
-        _dists_by_mods = {k: v[0] for k, v in packages_distributions().items()}
+        try:
+            _dists_by_mods = {
+                k: v[0] for k, v in packages_distributions().items()
+            }
+        except FileNotFoundError:
+            # MetadataNotFound is only available in Python 3.15+
+            # https://docs.python.org/3.15/library/importlib.metadata.html
+            _dists_by_mods = {}
     return _dists_by_mods
 
 

Reply via email to