GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-160386: Apply changes from importlib_metadata 9.1 by jaraco · Pull Request #160387 · python/cpython

Conversation

@jaraco

@jaraco jaraco commented Oct 22, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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

  • Issue: Sync with importlib_metadata for Python 3.16 #160386

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@jaraco @claude
pythongh-160386: Apply changes from importlib_metadata 9.1
8106aa0
Syncs importlib_metadata 9.0.1 and 9.1.0 into importlib.metadata.

Discovery now considers a path's children in reverse lexicographic
order, so the greater of several metadata directories for one
distribution wins and stale metadata from an unclean upgrade no longer
shadows the version in use (pythongh-100666). Distribution.name and .version
identify the distribution in the KeyError raised for a missing required
field, and PathDistribution renders as its metadata path. EntryPoint
validates its value on use rather than on construction. diagnose
describes a distribution it cannot name instead of crashing.
SimplePath.joinpath and __truediv__ take other positional-only.

Prepared.normalize returns to the re.sub implementation, the hand-rolled
version from pythongh-143658 having been reverted upstream.

Removes _typing.py and its import. Its only export, md_none, lost its
last call site in pythongh-143387, but the import survived that merge.

Co-Authored-By: Claude Opus 5 <[email protected]>
@jaraco
jaraco requested review from FFY00 and warsaw as code owners October 22, 2026 22:53
@bedevere-app bedevere-app Bot added the awaiting core review label Oct 22, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Oct 22, 2026
Sync with importlib_metadata for Python 3.16 #160386
Open
@jaraco

jaraco commented Oct 31, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

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.

Don't worry too much about this change. It gets rolled back in a subsequent version that I also plan to merge (python/importlib_metadata#552) (and replaced with a more sophisticated handling of invalid metadata directories python/importlib_metadata#553).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

warsaw
warsaw approved these changes Oct 31, 2026
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Oct 31, 2026
@warsaw
Merge branch 'main' into sync/importlib_metadata-9.1.0
60b4be2
@bedevere-app bedevere-app Bot added the type-feature A feature request or enhancement label Oct 31, 2026
@jaraco jaraco mentioned this pull request Oct 31, 2026
Install the finder only after the module is initialized python/importlib_metadata#556
Merged
@jaraco
jaraco merged commit 5a97efe into python:main Oct 31, 2026
55 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting merge label Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@warsaw warsaw warsaw approved these changes
@FFY00 FFY00 Awaiting requested review from FFY00 FFY00 is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

type-feature A feature request or enhancement

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@jaraco @warsaw
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.