Skip to content

gh-112821: Fix rlcompleter failures on objects with descriptors#149577

Open
mdboom wants to merge 2 commits intopython:mainfrom
mdboom:issue112821
Open

gh-112821: Fix rlcompleter failures on objects with descriptors#149577
mdboom wants to merge 2 commits intopython:mainfrom
mdboom:issue112821

Conversation

@mdboom
Copy link
Copy Markdown
Contributor

@mdboom mdboom commented May 8, 2026

This issue came to light for me when it was discovered that autocompletion didn't work for a library I help maintain, written mainly in Cython. Cython implements @property-annotated methods on its cdef classes as getset descriptors. The rlcompleter logic doesn't exclude these (like it does regular Python properties) since isinstance(member, property) is False. It then goes on to call the getter, which in some cases (in our library at least) raises an exception. Any exception other than an AttributeError causes the rlcompleter to short circuit completely and not offer any options.

This is a more surgical (rlcompleter-only) solution than what was proposed in #112821. If adding ABCs is preferred, I could do that.

Restore the try/except removed in #27401
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).

#112821 also mentioned:

This might cause false positives for method descriptors though.

I think this is handled here, but I also may not fully understand this specific issue.

@mdboom mdboom added type-bug An unexpected behavior, bug, or error 3.13 bugs and security fixes 3.14 bugs and security fixes topic-repl Related to the interactive shell 3.15 pre-release feature fixes, bugs and security fixes 3.16 new features, bugs and security fixes labels May 8, 2026
@python-cla-bot
Copy link
Copy Markdown

python-cla-bot Bot commented May 8, 2026

All commit authors signed the Contributor License Agreement.

CLA signed

@picnixz picnixz added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes and removed 3.13 bugs and security fixes 3.14 bugs and security fixes 3.15 pre-release feature fixes, bugs and security fixes 3.16 new features, bugs and security fixes type-bug An unexpected behavior, bug, or error topic-repl Related to the interactive shell labels May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants