Title: functools.singledispatch registration prioritizes the types of normal arguments before positional-only ones · Issue #143886 · python/cpython · GitHub
Open Graph Title: functools.singledispatch registration prioritizes the types of normal arguments before positional-only ones · Issue #143886 · python/cpython
X Title: functools.singledispatch registration prioritizes the types of normal arguments before positional-only ones · Issue #143886 · python/cpython
Description: Bug report Bug description: Decorator-based functools.singledispatch registration prioritizes the types of normal arguments before positional-only ones when getting "the type of the first argument". This means that a function of def f(po...
Open Graph Description: Bug report Bug description: Decorator-based functools.singledispatch registration prioritizes the types of normal arguments before positional-only ones when getting "the type of the first argument"...
X Description: Bug report Bug description: Decorator-based functools.singledispatch registration prioritizes the types of normal arguments before positional-only ones when getting "the type of the first argu...
Opengraph URL: https://github.com/python/cpython/issues/143886
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"functools.singledispatch registration prioritizes the types of normal arguments before positional-only ones","articleBody":"# Bug report\n\n### Bug description:\n\nDecorator-based `functools.singledispatch` registration prioritizes the types of normal arguments before positional-only ones when getting [\"the type of the first argument\"](https://docs.python.org/3/library/functools.html#functools.singledispatch).\n\nThis means that a function of `def f(pos: str, /, other: int)` will be registered to be dispatched for `other`'s type (`int`) instead of `pos` (`str`).\n\nTo reproduce:\n\n```python\nimport functools\n\n@functools.singledispatch\ndef f(arg, /, extra):\n return f\"{arg}: undispatched type\"\n\n@f.register\ndef f_int(arg: int, /, extra: str):\n return f\"{arg} is a {type(arg)} (dispatched by int)\"\n\n@f.register\ndef f_str(arg: str, /, extra: int):\n return f\"{arg} is a {type(arg)} (dispatched by str)\"\n\nprint(f(None, \"extra\"))\nprint(f(1, \"extra\"))\nprint(f(\"s\", \"extra\"))\n```\n\nResult:\n```\nNone: undispatched type\n1 is a \u003cclass 'int'\u003e (dispatched by str)\ns is a \u003cclass 'str'\u003e (dispatched by int)\n```\n\nExpected:\n```\nNone: undispatched type\n1 is a \u003cclass 'int'\u003e (dispatched by int)\ns is a \u003cclass 'str'\u003e (dispatched by str)\n```\n\n\n### CPython versions tested on:\n\n3.9, 3.10, 3.11, 3.12, 3.13, 3.14, CPython main branch\n\n### Operating systems tested on:\n\nmacOS\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-143888\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/pR0Ps","@type":"Person","name":"pR0Ps"},"datePublished":"2026-01-15T18:53:42.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/143886/cpython/issues/143886"}
| 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:4cf3e54e-7b91-c4f6-e8da-b178090b6191 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EDA2:1E6D3F:184A334:2058D67:6969ACA5 |
| html-safe-nonce | 1de52273430753e24357881f4d8082feb3da6020df03dd298c3c543e98add5c6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFREEyOjFFNkQzRjoxODRBMzM0OjIwNThENjc6Njk2OUFDQTUiLCJ2aXNpdG9yX2lkIjoiMTk0Mjg2ODg0MzY5MTYxNzQ0NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | e9da41907b41f6ff7014c24fe05bf79c627ed2302689be167f75dcd5256d9b00 |
| hovercard-subject-tag | issue:3818745798 |
| 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/143886/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9e494f21ffb895a561c7a6c168aa63a5ab63a98543ece0c31f14d12661105a85/python/cpython/issues/143886 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9e494f21ffb895a561c7a6c168aa63a5ab63a98543ece0c31f14d12661105a85/python/cpython/issues/143886 |
| og:image:alt | Bug report Bug description: Decorator-based functools.singledispatch registration prioritizes the types of normal arguments before positional-only ones when getting "the type of the first argument"... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | pR0Ps |
| hostname | github.com |
| expected-hostname | github.com |
| None | 24c4c97a2d520cb286b35e1a4c22d7a4df3c26a2fa28dd7cdf0e65db327b4de7 |
| 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 | 124667f43168afb6c9c03b7c02eb5b1d2e1be3d9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width