Title: `property` assumes that its subclasses have __dict__ · Issue #98963 · python/cpython · GitHub
Open Graph Title: `property` assumes that its subclasses have __dict__ · Issue #98963 · python/cpython
X Title: `property` assumes that its subclasses have __dict__ · Issue #98963 · python/cpython
Description: property's tp_init has this code: if (Py_IS_TYPE(self, &PyProperty_Type)) { Py_XSETREF(self->prop_doc, prop_doc); } else { /* If this is a property subclass, put __doc__ in dict of the subclass instance instead, otherwise it gets shadowe...
Open Graph Description: property's tp_init has this code: if (Py_IS_TYPE(self, &PyProperty_Type)) { Py_XSETREF(self->prop_doc, prop_doc); } else { /* If this is a property subclass, put __doc__ in dict of the subclass ins...
X Description: property's tp_init has this code: if (Py_IS_TYPE(self, &PyProperty_Type)) { Py_XSETREF(self->prop_doc, prop_doc); } else { /* If this is a property subclass, put __doc__ in dict of the s...
Opengraph URL: https://github.com/python/cpython/issues/98963
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`property` assumes that its subclasses have __dict__","articleBody":"`property`'s `tp_init` has [this code](https://github.com/python/cpython/blob/f042646595d1cdd2ecdc15222b1766f746d010f0/Objects/descrobject.c#L1813-L1832):\r\n\r\n```\r\n if (Py_IS_TYPE(self, \u0026PyProperty_Type)) {\r\n Py_XSETREF(self-\u003eprop_doc, prop_doc);\r\n } else {\r\n /* If this is a property subclass, put __doc__\r\n in dict of the subclass instance instead,\r\n otherwise it gets shadowed by __doc__ in the\r\n class's dict. */\r\n\r\n /*...*/\r\n PyObject_SetAttr((PyObject *)self, \u0026_Py_ID(__doc__), prop_doc);\r\n /*...*/\r\n }\r\n```\r\n\r\nThis assumes that subclasses of `property` have a `__dict__` (or a `__doc__` attribute settable by other means). That is the case when subclassed using the `class` statement, but might not be true using C.\r\nA C-API reproducer is at https://github.com/wjakob/inheritance_issue/blob/master/inheritance_issue.c\r\n\r\nI don't see a good way to fix this. We could:\r\n- document that subclasses need to set `Py_TPFLAGS_MANAGED_DICT` (or provide a `__doc__` descriptor), or \r\n- ignore the `AttributeError`, unless `__doc__` was set explicitly?\n\n\u003c!-- gh-pr-number: gh-99058 --\u003e\n* PR: gh-99058\n\u003c!-- /gh-pr-number --\u003e\n\n\n\u003c!-- gh-pr-number: gh-105262 --\u003e\n* PR: gh-105262\n\u003c!-- /gh-pr-number --\u003e\n\n\n\u003c!-- gh-pr-number: gh-105297 --\u003e\n* PR: gh-105297\n\u003c!-- /gh-pr-number --\u003e\n","author":{"url":"https://github.com/encukou","@type":"Person","name":"encukou"},"datePublished":"2022-11-01T14:43:16.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":19},"url":"https://github.com/98963/cpython/issues/98963"}
| 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:9a94e77b-481c-b702-2411-a88f6a015873 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B816:15FF28:14DDDBC:1D4007C:696A4108 |
| html-safe-nonce | e1f88b1ad9cdf6a39f61ba2c8c7e47c2de1ec38df9607fc9ccafa076367898a4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCODE2OjE1RkYyODoxNEREREJDOjFENDAwN0M6Njk2QTQxMDgiLCJ2aXNpdG9yX2lkIjoiNTQyOTgzMTUwMTQzNzYxNjM5MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | edcb2fa07244ebbcf73893c050b81efd0e34730058058d5a819c58c5f061779c |
| hovercard-subject-tag | issue:1431547618 |
| 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/98963/issue_layout |
| twitter:image | https://opengraph.githubassets.com/816372f87a6b35316b163a8fd3569db8a4b63f3e07802a5a8a7e870c6aaa8614/python/cpython/issues/98963 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/816372f87a6b35316b163a8fd3569db8a4b63f3e07802a5a8a7e870c6aaa8614/python/cpython/issues/98963 |
| og:image:alt | property's tp_init has this code: if (Py_IS_TYPE(self, &PyProperty_Type)) { Py_XSETREF(self->prop_doc, prop_doc); } else { /* If this is a property subclass, put __doc__ in dict of the subclass ins... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | encukou |
| hostname | github.com |
| expected-hostname | github.com |
| None | 321736bfdb3f591415ae895a0459bec204b26a76caf47ba5c980634cfacc4538 |
| 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 | 13581a31d51edf4a3aca179e10890a4d4f9b6d76 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width