8000 gh-112948: Make pdb completion similar to repl completion by gaogaotiantian · Pull Request #112950 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-112948: Make pdb completion similar to repl completion #112950

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 3 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file 8000
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use locals+globals as namespaces
  • Loading branch information
gaogaotiantian committed Dec 11, 2023
commit ed5731ad9272824f6fb03f3f18b9e56a39453db6
2 changes: 1 addition & 1 deletion Lib/pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ def completedefault(self, text, line, begidx, endidx):
# Use rlcompleter to do the completion
state = 0
matches = []
completer = Completer()
completer = Completer(self.curframe.f_globals | self.curframe_locals)
while (match := completer.complete(text, state)) is not None:
matches.append(match)
state += 1
Expand Down
18 changes: 18 additions & 0 deletions Lib/test/test_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -3351,6 +3351,24 @@ def test_builtin_completion(self):

self.assertIn(b'special', output)

def test_local_namespace(self):
script = textwrap.dedent("""
def f():
original = "I live Pythin"
import pdb; pdb.Pdb().set_trace()
f()
""")

# Complete: original.replace('i', 'o')
input = b"orig\t.repl\t('i', 'o')\n"

# Continue
input += b"c\n"

output = run_pty(script, input)

self.assertIn(b'I love Python', output)

def test_multiline_completion(self):
script = textwrap.dedent("""
import pdb; pdb.Pdb().set_trace()
Expand Down
0