Skip to content

Commit 28965cc

Browse files
committed
[3.13] pythongh-140141: Properly break exception chain in importlib.metadata.Distribution.from_name (pythonGH-140142)
(cherry picked from commit bcced02) Co-authored-by: Bartosz Sławecki <[email protected]>
1 parent f09a6a2 commit 28965cc

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Lib/importlib/metadata/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ def from_name(cls, name: str) -> Distribution:
406406
try:
407407
return next(iter(cls.discover(name=name)))
408408
except StopIteration:
409-
raise PackageNotFoundError(name)
409+
raise PackageNotFoundError(name) from None
410410

411411
@classmethod
412412
def discover(
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
The :py:class:`importlib.metadata.PackageNotFoundError` traceback raised when
2+
``importlib.metadata.Distribution.from_name`` cannot discover a
3+
distribution no longer includes a transient :exc:`StopIteration` exception trace.
4+
5+
Contributed by Bartosz Sławecki in :gh:`140142`.

0 commit comments

Comments
 (0)