Skip to content

Commit 59f3712

Browse files
Carreaumeeseeksmachine
authored andcommitted
Backport PR #12826: IPDB: "context" command
1 parent 3c039d4 commit 59f3712

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

IPython/core/debugger.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,20 @@ def do_down(self, arg):
796796
do_d = do_down
797797
do_u = do_up
798798

799+
def do_context(self, context):
800+
"""context number_of_lines
801+
Set the number of lines of source code to show when displaying
802+
stacktrace information.
803+
"""
804+
try:
805+
new_context = int(context)
806+
if new_context <= 0:
807+
raise ValueError()
808+
except ValueError:
809+
self.error("The 'context' command requires a positive integer argument.")
810+
self.context = new_context
811+
812+
799813
class InterruptiblePdb(Pdb):
800814
"""Version of debugger where KeyboardInterrupt exits the debugger altogether."""
801815

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
New "context" command in ipdb
2+
-----------------------------
3+
4+
It is now possible to change the number of lines shown in the backtrace
5+
information in ipdb using "context" command.

0 commit comments

Comments
 (0)