Title: `importlib.metadata.version(None)` returns arbitrary version number · Issue #93259 · python/cpython · GitHub
Open Graph Title: `importlib.metadata.version(None)` returns arbitrary version number · Issue #93259 · python/cpython
X Title: `importlib.metadata.version(None)` returns arbitrary version number · Issue #93259 · python/cpython
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 err...
Open Graph 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 on...
X 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 expecte...
Opengraph URL: https://github.com/python/cpython/issues/93259
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`importlib.metadata.version(None)` returns arbitrary version number","articleBody":"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.\r\n\r\nI would have expected one of the following instead:\r\n- raise an error saying that the `distribution_name` parameter cannot be `None`, or\r\n- explain what the return value means in the [relevant documentation](https://docs.python.org/3.10/library/importlib.metadata.html#version).\r\n\r\nThe 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.\r\n\r\n```\r\n\u003e\u003e\u003e import sys\r\n\u003e\u003e\u003e print(sys.version)\r\n3.10.0 (tags/v3.10.0:b494f59, Oct 4 2021, 19:00:18) [MSC v.1929 64 bit (AMD64)]\r\n\u003e\u003e\u003e import importlib.metadata\r\n\u003e\u003e\u003e importlib.metadata.version(None)\r\n'21.2.3'\r\n```\r\n\r\nI 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.\r\n\r\n**System information**\r\n\r\n- CPython versions tested on: 3.10.0\r\n- Operating system and architecture: Windows 10 Enterprise (64-bit operating system, x64-based processor)\r\n","author":{"url":"https://github.com/peterzahemszky","@type":"Person","name":"peterzahemszky"},"datePublished":"2022-05-26T14:28:20.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/93259/cpython/issues/93259"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:53e1bc46-7d22-7a8c-605b-e916898d1df0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DA54:2253BD:79920:AAC53:696A6A00 |
| html-safe-nonce | 25a31bd6447dad55c95382f7959c0b9f4009c0b4858093adfd6a3981bfa21500 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQTU0OjIyNTNCRDo3OTkyMDpBQUM1Mzo2OTZBNkEwMCIsInZpc2l0b3JfaWQiOiI0ODgyMjQ3NTc5NDk2NzcwMDQ4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 312e986bb345883a8d20ef43f48f38753f1ef07f8aee5db8731938957f966229 |
| hovercard-subject-tag | issue:1249646560 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/93259/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2ccab08be22257863c2a77410876db12a1ca04316e4315638a1e447d3c4fa2a7/python/cpython/issues/93259 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2ccab08be22257863c2a77410876db12a1ca04316e4315638a1e447d3c4fa2a7/python/cpython/issues/93259 |
| og:image:alt | 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 on... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | peterzahemszky |
| hostname | github.com |
| expected-hostname | github.com |
| None | 6fea32d5b7276b841b7a803796d9715bc6cfb31ed549fdf9de2948ac25d12ba6 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f2d9f6432a5a115ec709295ae70623f33bb80aee |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width