gh-140141: Properly break exception chain in importlib.metadata.Distribution.from_name (#140142)
This commit is contained in:
@@ -457,7 +457,7 @@ class Distribution(metaclass=abc.ABCMeta):
|
|||||||
try:
|
try:
|
||||||
return next(iter(cls._prefer_valid(cls.discover(name=name))))
|
return next(iter(cls._prefer_valid(cls.discover(name=name))))
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
raise PackageNotFoundError(name)
|
raise PackageNotFoundError(name) from None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def discover(
|
def discover(
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
The :py:class:`importlib.metadata.PackageNotFoundError` traceback raised when
|
||||||
|
``importlib.metadata.Distribution.from_name`` cannot discover a
|
||||||
|
distribution no longer includes a transient :exc:`StopIteration` exception trace.
|
||||||
|
|
||||||
|
Contributed by Bartosz Sławecki in :gh:`140142`.
|
||||||
Reference in New Issue
Block a user