Skip to content

Commit 653f12b

Browse files
[3.15] gh-143387: Update docs to reflect the behavior and note the changed version. (GH-150095) (#150106)
gh-143387: Update docs to reflect the behavior and note the changed version. (GH-150095) (cherry picked from commit 192796c) Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
1 parent eb7be9a commit 653f12b

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

Doc/library/importlib.metadata.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ You can also get a :ref:`distribution's version number <version>`, list its
105105
current Python environment.
106106

107107

108+
.. exception:: MetadataNotFound
109+
110+
Subclass of :class:`FileNotFoundError` raised when attempting to load metadata
111+
from a distribution folder that is empty or otherwise does not contain a
112+
metadata file.
113+
114+
108115
Functional API
109116
==============
110117

@@ -224,6 +231,9 @@ Distribution metadata
224231
Raises :exc:`PackageNotFoundError` if the named distribution
225232
package is not installed in the current Python environment.
226233

234+
Raises :exc:`MetadataNotFound` if a distribution package is
235+
present but no METADATA file is present.
236+
227237
.. class:: PackageMetadata
228238

229239
A concrete implementation of the
@@ -252,6 +262,12 @@ all the metadata in a JSON-compatible form per :PEP:`566`::
252262
The full set of available metadata is not described here.
253263
See the PyPA `Core metadata specification <https://packaging.python.org/en/latest/specifications/core-metadata/#core-metadata>`_ for additional details.
254264

265+
.. versionchanged:: 3.15
266+
Previously and incidentally, if a METADATA file was missing from a distribution, an
267+
empty ``PackageMetadata`` would be returned, indistinguishable from
268+
an empty METADATA file. Now, a missing METADATA file triggers a
269+
``MetadataNotFound`` exception.
270+
255271
.. versionchanged:: 3.10
256272
The ``Description`` is now included in the metadata when presented
257273
through the payload. Line continuation characters have been removed.
@@ -465,6 +481,9 @@ The same applies for :func:`entry_points` and :func:`files`.
465481
.. attribute:: metadata
466482
:type: PackageMetadata
467483

484+
Raises :exc:`MetadataNotFound` if the METADATA file is not present in
485+
the distribution.
486+
468487
There are all kinds of additional metadata available on :class:`!Distribution`
469488
instances as a :class:`PackageMetadata` instance::
470489

0 commit comments

Comments
 (0)