Title: inspect.ismethoddescriptor(): lack of __delete__() is not checked · Issue #120381 · python/cpython · GitHub
Open Graph Title: inspect.ismethoddescriptor(): lack of __delete__() is not checked · Issue #120381 · python/cpython
X Title: inspect.ismethoddescriptor(): lack of __delete__() is not checked · Issue #120381 · python/cpython
Description: Bug report Bug description: The inspect.ismethoddescriptor() function reports descriptor objects which implement __delete__() but not __set__() as method descriptors, even though they are, in fact, data descriptors: Actual behavior examp...
Open Graph Description: Bug report Bug description: The inspect.ismethoddescriptor() function reports descriptor objects which implement __delete__() but not __set__() as method descriptors, even though they are, in fact,...
X Description: Bug report Bug description: The inspect.ismethoddescriptor() function reports descriptor objects which implement __delete__() but not __set__() as method descriptors, even though they are, in fact,...
Opengraph URL: https://github.com/python/cpython/issues/120381
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"inspect.ismethoddescriptor(): lack of __delete__() is not checked","articleBody":"# Bug report\r\n\r\n### Bug description:\r\n\r\nThe `inspect.ismethoddescriptor()` function reports descriptor objects which implement `__delete__()` but not `__set__()` as *method descriptors*, even though they are, in fact, *data descriptors*:\r\n\r\nActual behavior example:\r\n\r\n```python\r\n\u003e\u003e\u003e import inspect\r\n\u003e\u003e\u003e class Descriptor:\r\n... def __get__(self, *_): pass\r\n... def __delete__(self, *_): pass # Note: `__set__()` *not* defined.\r\n...\r\n\u003e\u003e\u003e inspect.ismethoddescriptor(Descriptor()) # Wrong result:\r\nTrue\r\n```\r\n\r\nExpected result:\r\n\r\n```python\r\n\u003e\u003e\u003e inspect.ismethoddescriptor(Descriptor()) # Correct result:\r\nFalse\r\n```\r\n\r\nSee also: https://discuss.python.org/t/inspect-ismethoddescriptor-checks-for-the-lack-of-set-but-ignores-delete-should-it-be-fixed/55039\r\n\r\n***\r\n\r\nThere is an additional question: *to which Python versions should the fix be applied?*\r\n\r\nIMHO, the fix can be safely applied to the branches 3.14 (main) and 3.13 (still in the beta phase). Backporting it to the earlier versions might be considered too disruptive. Obviously, the decision will need to be made by a core developer, not me.\r\n\r\n***\r\n\r\n### CPython versions tested on:\r\n\r\n3.8, 3.9, 3.10, 3.11, 3.12, 3.13, CPython main branch\r\n\r\n\u003c!-- gh-linked-prs --\u003e\r\n### Linked PRs\r\n* gh-120383\r\n* gh-120684\n\u003c!-- /gh-linked-prs --\u003e\r\n","author":{"url":"https://github.com/zuo","@type":"Person","name":"zuo"},"datePublished":"2024-06-12T02:31:28.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/120381/cpython/issues/120381"}
| 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:c25c29f1-7c77-24b9-6194-88ed07fb8507 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9D4E:22391C:7738D2:9A7EA2:696B4CD1 |
| html-safe-nonce | 219dfc57f5c06fce58aeee5e7894b1e2f7bdf0276dd0eae4b0dc4305ed0d3f43 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RDRFOjIyMzkxQzo3NzM4RDI6OUE3RUEyOjY5NkI0Q0QxIiwidmlzaXRvcl9pZCI6IjU3Mjc5MTAzNjY0NDgxNDM1NjkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 31f9d4d09e3433e4a6a512a2da5f766ad8772e695a8e03c034fb64a3bfd976a1 |
| hovercard-subject-tag | issue:2347667050 |
| 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/120381/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5f1e219bd2be1a6aa498d7e0eb1a5136d7cedd70a7f443e5ed84652fcac4500f/python/cpython/issues/120381 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5f1e219bd2be1a6aa498d7e0eb1a5136d7cedd70a7f443e5ed84652fcac4500f/python/cpython/issues/120381 |
| og:image:alt | Bug report Bug description: The inspect.ismethoddescriptor() function reports descriptor objects which implement __delete__() but not __set__() as method descriptors, even though they are, in fact,... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | zuo |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| 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 | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width