Skip to content

gh-131123: Support completion in pdb for convenience variable attributes #131124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 12, 2025

Conversation

gaogaotiantian
Copy link
Member

@gaogaotiantian gaogaotiantian commented Mar 11, 2025

@picnixz picnixz changed the title gh-131123: Support completion for convenience variable attributes gh-131123: Support completion in pdb for convenience variable attributes Mar 12, 2025
for part in dotted[1:-1]:
obj = getattr(obj, part)
except (KeyError, AttributeError):
return []
prefix = '.'.join(dotted[:-1]) + '.'
return [prefix + n for n in dir(obj) if n.startswith(dotted[-1])]
else:
if text.startswith("$"):
# Complete convenience variables
conv_vars = self.curframe.f_globals.get('__pdb_convenience_variables', {})
Copy link
Member

Choose a reason for hiding this comment

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

Here you use get and in line 985 you don't. Is that correct?

Copy link
Member Author

@gaogaotiantian gaogaotiantian Mar 12, 2025

Choose a reason for hiding this comment

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

line 985 is in a try block which has a KeyError catch. If the first part starts with $ and does not exist in globals, we should just return []. That's also how it handles the other parts.

@gaogaotiantian gaogaotiantian merged commit b528669 into python:main Mar 12, 2025
43 checks passed
@gaogaotiantian gaogaotiantian deleted the pdb-convvar-completion branch March 12, 2025 21:23
plashchynski pushed a commit to plashchynski/cpython that referenced this pull request Mar 17, 2025
seehwan pushed a commit to seehwan/cpython that referenced this pull request Apr 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants