Repository navigation
Sync with importlib_metadata for Python 3.16 #160386
Copy link
Copy link
Open
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-importlibtype-featureA feature request or enhancementA feature request or enhancement
Description
Tracking issue for applying importlib_metadata changes to importlib.metadata in 3.16, continuing the pattern of #132947 (3.15) and #117089 (3.13).
This covers importlib_metadata 9.0.1 and 9.1.0:
- Prefer the greater metadata directory when a path supplies more than one. Children are now considered in reverse lexicographic order, so stale metadata left behind by an interrupted or unclean upgrade no longer shadows the version in use (Invalid metadata directory leads to errors #100666).
- Identify the distribution when a required metadata field is missing.
Distribution.nameand.versionnow raise aKeyErrornaming both the field and the distribution, andPathDistributionrenders itself as its metadata path. - Defer
EntryPoint.valuevalidation until use. Construction no longer validates, so one malformed entry point no longer prevents entry points in other groups from being selected (Using entry-pointvaluefor non-object references importlib_metadata#523). importlib.metadata.diagnoseno longer crashes on a metadata directory with no metadata file, or whose metadata declares no name; such distributions are reported by their location (Diagnose crashes on empty metadata directory importlib_metadata#548).SimplePath.joinpathandSimplePath.__truediv__takeotherpositional-only, sopathlib.Pathsatisfies the protocol under type checkers that compare parameter names (SimplePath rejects pathlib.Path: joinpath and __truediv__ are not positional-only importlib_metadata#542).
Two further items that are cleanups rather than behavior changes:
Prepared.normalizereturns to there.subimplementation. The hand-rolled version from importlib.metadata: Usestr.translateto improve performance ofimportlib.metadata.Prepared.normalized#143658 was reverted upstream, so keeping it here would be fresh drift.Lib/importlib/metadata/_typing.pyis removed along with its import. Its only export,md_none, lost its last call site whenDistribution.metadatabegan raisingMetadataNotFound(Regression: importlib.metadata.PathDistribution.requires raises AttributeError, name/version raises TypeError #143387), but the import line survived the merge that landed that change, leaving an unused module imported by nothing.
Linked PRs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-importlibtype-featureA feature request or enhancementA feature request or enhancement
Activity