GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-139819: rlcompleter – avoid suggesting attributes not accessible on instances by ttw225 · Pull Request #139820 · python/cpython

Conversation

@ttw225

@ttw225 ttw225 commented Oct 9, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Fix tab-completion suggesting names that are not accessible on instances
(e.g., Enum members showing __name__).

Change

In rlcompleter.attr_matches(), when getattr(thisobject, word, None)
is None, only add the candidate if hasattr(thisobject, word) is true.

Effect

Removes bogus suggestions without affecting valid completions.

Bogus suggestions

['Color.BLUE.__iter__',
 'Color.BLUE.__getitem__',
 'Color.BLUE.__members__',
 'Color.BLUE.__contains__',
 'Color.BLUE.__qualname__',
 'Color.BLUE.__len__',
 'Color.BLUE.__name__']
# Additionally seen among bogus suggestions:
'Enum.__abstractmethods__'
  • Issue: rlcompleter suggests attributes not accessible on instances (e.g., Enum member __name__) #139819

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ttw225
fix(Lib/rlcompleter): prevent suggesting non-existent attributes
8466abc
@bedevere-app bedevere-app Bot added the awaiting review label Oct 9, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Oct 9, 2025
rlcompleter suggests attributes not accessible on instances (e.g., Enum member __name__) #139819
Closed
@ttw225
docs(NEWS.d): gh-issue-139819
1655dc6
@ttw225

ttw225 commented Oct 9, 2025

Copy link
Copy Markdown
Contributor Author

Noted the CI Test failure. I’m working on a fix and will push soon.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ttw225 added 6 commits October 9, 2025 18:05
@ttw225
refactor(Lib/rlcompleter.py): Simplify conditional expression
394432e
@ttw225
test(test_rlcompleter): adjust test_excessive_getattr call count expe…
d567f83
…ctations
@ttw225
fix(Lib/rlcompleter): handle unassigned __slots__ attributes in compl…
ad6ff8e
…etion
@ttw225
refactor(Lib/rlcompleter): use sentinel to properly handle None-value…
8d98bab
…d attributes
@ttw225
test(test_rlcompleter): update test_excessive_getattr for sentinel ap…
14bd61e
…proach
@ttw225
test(test_rlcompleter): remove unintended test_enum_member_completion…
76e32a3
… in rlcompleter tests
@ttw225

ttw225 commented Oct 9, 2025

Copy link
Copy Markdown
Contributor Author

Tests have passed. Thanks for reviewing!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Apr 30, 2026

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 30, 2026
@ethanfurman
Merge branch 'main' into fix/rlcompleter
7482968
@ethanfurman
ethanfurman merged commit 81c1cdc into python:main Jun 9, 2026
52 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting review label Jun 9, 2026
clin1234 pushed a commit to clin1234/cpython that referenced this pull request Jun 9, 2026
@ttw225 @ethanfurman unknown
pythongh-139819: rlcompleter – avoid suggesting attributes not access…
864de8d
…ible on instances (pythonGH-139820)

Co-authored-by: Ethan Furman <[email protected]>
danielhollas
danielhollas reviewed Jun 9, 2026
View reviewed changes
Comment thread Lib/rlcompleter.py
__all__ = ["Completer"]

# Sentinel object to distinguish "missing" from "present but None"
_SENTINEL = object()

@danielhollas danielhollas Jun 9, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this use the new sentinel builtin?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ttw225 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@Viicos Viicos Jun 10, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened #151222.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

danielhollas reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@ttw225 ttw225 mentioned this pull request Jun 10, 2026
docs(open-source): mark cpython/rlcompleter PR as merged ttw225/blog#14
Merged
@ttw225
ttw225 deleted the fix/rlcompleter branch June 11, 2026 02:41
philthompson10 pushed a commit to philthompson10/cpython that referenced this pull request Jun 17, 2026
@ttw225 @ethanfurman @philthompson10
pythongh-139819: rlcompleter – avoid suggesting attributes not access…
53ccdd0
…ible on instances (pythonGH-139820)

Co-authored-by: Ethan Furman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

2 more reviewers
@danielhollas danielhollas danielhollas left review comments
@Viicos Viicos Viicos left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

stale Stale PR or inactive for long period of time.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@ttw225 @danielhollas @Viicos @ethanfurman
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.