Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-104301: Allow leading whitespace in disambiguated pdb statements #104342

Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 11 additions & 3 deletions Doc/library/pdb.rst
Original file line number Diff line number Diff line change
Expand Up @@ -602,9 +602,17 @@ can be overridden by the local file.

Execute the (one-line) *statement* in the context of the current stack frame.
The exclamation point can be omitted unless the first word of the statement
resembles a debugger command. To set a global variable, you can prefix the
assignment command with a :keyword:`global` statement on the same line,
e.g.::
resembles a debugger command, e.g.:

.. code-block:: none

(Pdb) ! n=42
(Pdb)

To set a global variable, you can prefix the assignment command with a
:keyword:`global` statement on the same line, e.g.:

.. code-block:: none

(Pdb) global list_options; list_options = ['-l']
(Pdb)
Expand Down
11 changes: 7 additions & 4 deletions Lib/pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ def displayhook(self, obj):
self.message(repr(obj))

def default(self, line):
if line[:1] == '!': line = line[1:]
if line[:1] == '!': line = line[1:].strip()
locals = self.curframe_locals
globals = self.curframe.f_globals
try:
Expand Down Expand Up @@ -1642,9 +1642,12 @@ def help_exec(self):

Execute the (one-line) statement in the context of the current
stack frame. The exclamation point can be omitted unless the
first word of the statement resembles a debugger command. To
assign to a global variable you must always prefix the command
with a 'global' command, e.g.:
first word of the statement resembles a debugger command, e.g.:
(Pdb) ! n=42
(Pdb)

To assign to a global variable you must always prefix the command with
a 'global' command, e.g.:
(Pdb) global list_options; list_options = ['-l']
(Pdb)
"""
Expand Down
13 changes: 8 additions & 5 deletions Lib/pydoc_data/topics.py
Original file line number Diff line number Diff line change
Expand Up @@ -5283,11 +5283,14 @@
'current\n'
' stack frame. The exclamation point can be omitted unless the '
'first\n'
' word of the statement resembles a debugger command. To set '
'a\n'
' global variable, you can prefix the assignment command with '
'a\n'
' "global" statement on the same line, e.g.:\n'
' word of the statement resembles a debugger command, e.g.:'
'\n'
' (Pdb) ! n=42\n'
' (Pdb)\n'
'\n'
' To set a global variable, you can prefix the assignment command '
' with \n'
' a "global" statement on the same line, e.g.:\n'
'\n'
" (Pdb) global list_options; list_options = ['-l']\n"
' (Pdb)\n'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow leading whitespace in disambiguated statements in :mod:`pdb`.