From 73e6371c5e4d01501fcbf9b29b800c72d937a2d1 2021-05-13 22:03:13 From: Blazej Michalik Date: 2021-05-13 22:03:13 Subject: [PATCH] Nicer output for erroneous args to %rerun -l --- diff --git a/IPython/core/magics/history.py b/IPython/core/magics/history.py index 3b95ee7..8771667 100644 --- a/IPython/core/magics/history.py +++ b/IPython/core/magics/history.py @@ -301,6 +301,14 @@ class HistoryMagics(Magics): opts, args = self.parse_options(parameter_s, 'l:g:', mode='string') if "l" in opts: # Last n lines n = int(opts['l']) + + if n == 0: + print("Requested 0 last lines - nothing to run") + return + elif n < 0: + print("Number of lines to rerun cannot be negative") + return + hist = self.shell.history_manager.get_tail(n) elif "g" in opts: # Search p = "*"+opts['g']+"*"