You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[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>
Copy file name to clipboardExpand all lines: Doc/library/importlib.metadata.rst
+19Lines changed: 19 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -105,6 +105,13 @@ You can also get a :ref:`distribution's version number <version>`, list its
105
105
current Python environment.
106
106
107
107
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
+
108
115
Functional API
109
116
==============
110
117
@@ -224,6 +231,9 @@ Distribution metadata
224
231
Raises :exc:`PackageNotFoundError` if the named distribution
225
232
package is not installed in the current Python environment.
226
233
234
+
Raises :exc:`MetadataNotFound` if a distribution package is
235
+
present but no METADATA file is present.
236
+
227
237
.. class:: PackageMetadata
228
238
229
239
A concrete implementation of the
@@ -252,6 +262,12 @@ all the metadata in a JSON-compatible form per :PEP:`566`::
252
262
The full set of available metadata is not described here.
253
263
See the PyPA `Core metadata specification <https://packaging.python.org/en/latest/specifications/core-metadata/#core-metadata>`_ for additional details.
254
264
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
+
255
271
.. versionchanged:: 3.10
256
272
The ``Description`` is now included in the metadata when presented
257
273
through the payload. Line continuation characters have been removed.
@@ -465,6 +481,9 @@ The same applies for :func:`entry_points` and :func:`files`.
465
481
.. attribute:: metadata
466
482
:type: PackageMetadata
467
483
484
+
Raises :exc:`MetadataNotFound` if the METADATA file is not present in
485
+
the distribution.
486
+
468
487
There are all kinds of additional metadata available on :class:`!Distribution`
469
488
instances as a :class:`PackageMetadata` instance::
0 commit comments