← 返回首页
`importlib.metadata.version(None)` returns arbitrary version number · Issue #93259 · python/cpython · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

importlib.metadata.version(None) returns arbitrary version number #93259

New issue
New issue

Description

The version() function of the importlib.metadata package returns an arbitrary version number when called with None. There's no documentation on what the return value means.

I would have expected one of the following instead:

  • raise an error saying that the distribution_name parameter cannot be None, or
  • explain what the return value means in the relevant documentation.

The current behaviour is confusing as one could think, for example, that the return value is the version of the project/package they call it from.

>>> import sys >>> print(sys.version) 3.10.0 (tags/v3.10.0:b494f59, Oct 4 2021, 19:00:18) [MSC v.1929 64 bit (AMD64)] >>> import importlib.metadata >>> importlib.metadata.version(None) '21.2.3'

I looks like the return value is the version of an arbitrary package installed in the Python virtual environment. Calling the function repeatedly seems to give the same value, but installing a new package can cause the return value to change.

System information

  • CPython versions tested on: 3.10.0
  • Operating system and architecture: Windows 10 Enterprise (64-bit operating system, x64-based processor)

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    • Open in GitHub Copilot app

    Footer

    © 2026 GitHub, Inc.