diff --git a/IPython/core/debugger.py b/IPython/core/debugger.py index 71a94ed..5d1286b 100644 --- a/IPython/core/debugger.py +++ b/IPython/core/debugger.py @@ -806,6 +806,20 @@ class Pdb(OldPdb): 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.""" diff --git a/docs/source/whatsnew/pr/ipdb-context-command.rst b/docs/source/whatsnew/pr/ipdb-context-command.rst new file mode 100644 index 0000000..80a3bf8 --- /dev/null +++ b/docs/source/whatsnew/pr/ipdb-context-command.rst @@ -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.