Syncs importlib_metadata 9.0.1 and 9.1.0 into importlib.metadata, following the development methodology. The upstream cpython branch is at a18aeb314 and the two trees are byte-identical.
Behavior changes
Prefer the greater metadata directory (#100666). FastPath.children() results are now taken in reverse lexicographic order, so when a path supplies more than one metadata directory for a distribution — as an interrupted or unclean upgrade may leave behind — the greater one is found first and the stale one no longer shadows the version in use. The ordering is lexicographic on the directory name rather than on the parsed version, so it approximates a preference for the newer version rather than guaranteeing it; the docstring says so.
Identify the distribution in metadata errors. Distribution.name and Distribution.version wrap the KeyError from a missing required field to name both the field and the distribution, and PathDistribution.__str__ renders as its metadata path, so a distribution whose metadata cannot name it is still identifiable.
Defer EntryPoint value validation. Validation moves off __init__ to the point of use, so one malformed entry point no longer prevents entry points in other groups from being selected.
diagnose no longer crashes on a metadata directory with no metadata file, or whose metadata declares no name. Such distributions are reported by location.
SimplePath protocol takes other positional-only on joinpath and __truediv__, so pathlib.Path satisfies it under type checkers that compare parameter names.
Two cleanups
Prepared.normalize returns to the re.sub implementation. The hand-rolled version from #143658 was reverted upstream, and keeping it here would be fresh drift between the trees.
Lib/importlib/metadata/_typing.py is removed along with its import. Its only export, md_none, lost its last call site in #143387, which removed the three md_none(...) wrappers but left from ._typing import md_none in place — the import block is a standing conflict region between the two trees, since it carries entries the stdlib cannot have, and the line survived the hand resolution. Nothing has imported the name since, so the module and the import go together.
Testing
./python.exe -m test test_importlib passes: 1,226 tests run, 65 skipped. The 127 doctests across the changed modules also pass, including the new ones on PathDistribution.__str__ and diagnose.describe.
🤖 Generated with Claude Code