Skip to content
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
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Check if any expression is being displayed
  • Loading branch information
gaogaotiantian committed Mar 25, 2023
commit 484b882ffc05a9828dc5ee20ce060c5a4e587443
9 changes: 6 additions & 3 deletions Lib/pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -1436,9 +1436,12 @@ def do_display(self, arg):
Without expression, list all display expressions for the current frame.
"""
if not arg:
self.message('Currently displaying:')
for item in self.displaying.get(self.curframe, {}).items():
self.message('%s: %r' % item)
if self.displaying:
self.message('Currently displaying:')
for item in self.displaying.get(self.curframe, {}).items():
self.message('%s: %r' % item)
else:
self.message('No expression is being displayed')
else:
val, exc = self._getval_except(arg)
if isinstance(exc, SyntaxError):
Expand Down
3 changes: 3 additions & 0 deletions Lib/test/test_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ def test_pdb_display_command():

>>> with PdbTestInput([ # doctest: +ELLIPSIS
... 'display +',
... 'display',
... 'display a',
... 'n',
... 'display',
Expand All @@ -603,6 +604,8 @@ def test_pdb_display_command():
-> a = 1
(Pdb) display +
Unable to display "+": SyntaxError
(Pdb) display
No expression is being displayed
(Pdb) display a
display a: 0
(Pdb) n
Expand Down