Title: Cannot call `issubclass()` against `typing.Protocol` on Python 3.12 · Issue #105237 · python/cpython · GitHub
Open Graph Title: Cannot call `issubclass()` against `typing.Protocol` on Python 3.12 · Issue #105237 · python/cpython
X Title: Cannot call `issubclass()` against `typing.Protocol` on Python 3.12 · Issue #105237 · python/cpython
Description: Bug report On Python 3.11, you can do this: >>> import typing >>> issubclass(object, typing.Protocol) False But on Python 3.12 (following the backport of c05c31d), this raises: >>> import typing >>> issubclass(object, typing.Protocol) Tr...
Open Graph Description: Bug report On Python 3.11, you can do this: >>> import typing >>> issubclass(object, typing.Protocol) False But on Python 3.12 (following the backport of c05c31d), this raises: >>> import typing >>...
X Description: Bug report On Python 3.11, you can do this: >>> import typing >>> issubclass(object, typing.Protocol) False But on Python 3.12 (following the backport of c05c31d), this raises: &g...
Opengraph URL: https://github.com/python/cpython/issues/105237
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Cannot call `issubclass()` against `typing.Protocol` on Python 3.12","articleBody":"# Bug report\r\n\r\nOn Python 3.11, you can do this:\r\n\r\n```pycon\r\n\u003e\u003e\u003e import typing\r\n\u003e\u003e\u003e issubclass(object, typing.Protocol)\r\nFalse\r\n```\r\n\r\nBut on Python 3.12 (following the backport of https://github.com/python/cpython/commit/c05c31db8c9dfd708b9857bb57f8e5f3ce40266d), this raises:\r\n\r\n```pycon\r\n\u003e\u003e\u003e import typing\r\n\u003e\u003e\u003e issubclass(object, typing.Protocol)\r\nTraceback (most recent call last):\r\n File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\r\n File \"C:\\Users\\alexw\\coding\\cpython\\Lib\\typing.py\", line 1797, in __subclasscheck__\r\n raise TypeError(\r\nTypeError: Instance and class checks can only be used with @runtime_checkable protocols\r\n```\r\n\r\nThe new behaviour doesn't make sense. That `TypeError` should only be triggered if a user is calling `issubclass()` against a _subclass_ of `typing.Protocol`. `typing.Protocol` itself should be exempted.\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-105239\n* gh-105316\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/AlexWaygood","@type":"Person","name":"AlexWaygood"},"datePublished":"2023-06-02T12:48:09.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/105237/cpython/issues/105237"}
| 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:71c04983-12a4-eaa0-f2c3-cd725c2c031c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BFE0:2ACFDC:9A652C:CF1449:69699199 |
| html-safe-nonce | 7b2e1f67f00fef3004a81da24041957470f9fe7b237fe50b3115c56003b528e2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRkUwOjJBQ0ZEQzo5QTY1MkM6Q0YxNDQ5OjY5Njk5MTk5IiwidmlzaXRvcl9pZCI6Ijg0NTQ1MTU0NTA0ODM1NTIyNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 796efbd11b0dd1ab9ce91f85874b6d0c39fd597dab2f5c787c1b007324d6a758 |
| hovercard-subject-tag | issue:1738143377 |
| 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/105237/issue_layout |
| twitter:image | https://opengraph.githubassets.com/aa2b8e77d35a8e6c91c31a73e8af805fa019bf7307d15aaf527379e5f405e4ec/python/cpython/issues/105237 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/aa2b8e77d35a8e6c91c31a73e8af805fa019bf7307d15aaf527379e5f405e4ec/python/cpython/issues/105237 |
| og:image:alt | Bug report On Python 3.11, you can do this: >>> import typing >>> issubclass(object, typing.Protocol) False But on Python 3.12 (following the backport of c05c31d), this raises: >>> import typing >>... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | AlexWaygood |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3542e147982176a7ebaa23dfb559c8af16f721c03ec560c68c56b64a0f35e751 |
| 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 | af80af7cc9e3de9c336f18b208a600950a3c187c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width