Title: Reconsider gh-88915 changes rlcompleter since exceptions in descriptors cause auto completion to fail · Issue #112821 · python/cpython · GitHub
Open Graph Title: Reconsider gh-88915 changes rlcompleter since exceptions in descriptors cause auto completion to fail · Issue #112821 · python/cpython
X Title: Reconsider gh-88915 changes rlcompleter since exceptions in descriptors cause auto completion to fail · Issue #112821 · python/cpython
Description: Bug report Bug description: In BPO 44752 (#88915), it was reported that tab completions execute @property getters. This was fixed in two stages: #27401: no longer call property getters #27401: No longer catch errors raised by a call to g...
Open Graph Description: Bug report Bug description: In BPO 44752 (#88915), it was reported that tab completions execute @property getters. This was fixed in two stages: #27401: no longer call property getters #27401: No l...
X Description: Bug report Bug description: In BPO 44752 (#88915), it was reported that tab completions execute @property getters. This was fixed in two stages: #27401: no longer call property getters #27401: No l...
Opengraph URL: https://github.com/python/cpython/issues/112821
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Reconsider gh-88915 changes rlcompleter since exceptions in descriptors cause auto completion to fail","articleBody":"# Bug report\r\n\r\n### Bug description:\r\n\r\nIn BPO [44752](https://bugs.python.org/issue44752) (#88915), it was reported that tab completions execute `@property` getters. This was fixed in two stages:\r\n\r\n1. https://github.com/python/cpython/pull/27401: no longer call property getters\r\n2. https://github.com/python/cpython/pull/27401: No longer catch errors raised by a call to getattr.\r\n\r\nIt looks like when investigating/solving this issue, it was unconsidered that `@property` isn't the only case where calling an underlying method might be undesirable. For example, in the [NVDA project](https://github.com/nvaccess/nvda), we have the following non-data descriptor (simplified for clarity):\r\n\r\n```python\r\nclass Getter:\r\n def __init__(self, fget):\r\n self.fget = fget\r\n\r\n def __get__(self, instance, owner):\r\n if isinstance(self.fget, classmethod):\r\n return self.fget.__get__(instance, owner)()\r\n elif instance is None:\r\n return self\r\n return self.fget(instance)\r\n\r\n\r\nclass SomeClass:\r\n @Getter\r\n def some_prop(self):\r\n raise NotImplementedError\r\n```\r\n\r\nIf we'd create an instance of SomeClass and try to autocomplete, `rlcompleter.Completer.attr_matches` would fail with the `NotImplementedError` raised by `some_prop`\r\n\r\nI'd propose one of the following:\r\n\r\n1. Restore the try/except removed in #27401\r\n2. Create abstract classes for descriptors in _collections_abc (e.g. ImplementsGet, ImplementsSet, ImplementsDelete) and in rlcompleter, rather than checking for `isinstance(obj, property)`, use `isinstance(obj, ImplementsGet)`. This might cause false positives for method descriptors though.\r\n\r\n### CPython versions tested on:\r\n\r\n3.11\r\n\r\n### Operating systems tested on:\r\n\r\nWindows\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-149577\n* gh-149656\n* gh-149657\n* gh-149658\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/LeonarddeR","@type":"Person","name":"LeonarddeR"},"datePublished":"2023-12-07T07:02:03Z","url":"https://github.com/python/cpython/issues/112821"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| 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:1e521844-0cdb-6057-8103-7f0cac0e8766 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8D26:F33A8:344217:491B7B:6AF84628 |
| html-safe-nonce | 610145e32c759730f585032afe574b65151da8deb476b39b397ec62c05df18b3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RDI2OkYzM0E4OjM0NDIxNzo0OTFCN0I6NkFGODQ2MjgiLCJ2aXNpdG9yX2lkIjoiODAxODU2ODYzNDc3Njk2MjYwMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | d3b12876aec8d0ded015fc8861cb8efc8fa1a34aefd9556db1f82a6325194745 |
| hovercard-subject-tag | issue:2030041844 |
| 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/112821/issue_layout |
| twitter:image | https://opengraph.githubassets.com/006ea132eb7c959d130d1cc4efa6fd6d73d7b6124a89c662853b2de9e62530f3/python/cpython/issues/112821 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/006ea132eb7c959d130d1cc4efa6fd6d73d7b6124a89c662853b2de9e62530f3/python/cpython/issues/112821 |
| og:image:alt | Bug report Bug description: In BPO 44752 (#88915), it was reported that tab completions execute @property getters. This was fixed in two stages: #27401: no longer call property getters #27401: No l... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | LeonarddeR |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5713ecd83001b2f55c3509fb7a292bf7d66d0f167c7ae87a9f7eaec5a52bf8db |
| 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 | 653be32ff5c755082a4db662491bfbbcfc9112c1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width