Skip to content

Commit

Permalink
Merge pull request #12826 from MrMino/ipdb_set_context_command
Browse files Browse the repository at this point in the history
IPDB: "context" command
  • Loading branch information
Carreau committed Feb 26, 2021
2 parents 96105e9 + a981855 commit 2ab3999
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
14 changes: 14 additions & 0 deletions IPython/core/debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,20 @@ def do_down(self, arg):
do_d = do_down
do_u = do_up

def do_context(self, context):
"""context number_of_lines
Set the number of lines of source code to show when displaying
stacktrace information.
"""
try:
new_context = int(context)
if new_context <= 0:
raise ValueError()
except ValueError:
self.error("The 'context' command requires a positive integer argument.")
self.context = new_context


class InterruptiblePdb(Pdb):
"""Version of debugger where KeyboardInterrupt exits the debugger altogether."""

Expand Down
5 changes: 5 additions & 0 deletions docs/source/whatsnew/pr/ipdb-context-command.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
New "context" command in ipdb
-----------------------------

It is now possible to change the number of lines shown in the backtrace
information in ipdb using "context" command.

0 comments on commit 2ab3999

Please sign in to comment.