From ffc5d1f5d47ffacfaa5b49241ae254616856eb7b 2007-09-08 14:00:21 From: vivainio Date: 2007-09-08 14:00:21 Subject: [PATCH] introduce UsageError --- diff --git a/IPython/ipapi.py b/IPython/ipapi.py index daa107b..aecf30e 100644 --- a/IPython/ipapi.py +++ b/IPython/ipapi.py @@ -86,6 +86,13 @@ class TryNext(Exception): self.args = args self.kwargs = kwargs +class UsageError(Exception): + """ Error in magic function arguments, etc. + + Something that probably won't warrant a full traceback, but should + nevertheless interrupt a macro / batch file. + """ + class IPyAutocall: """ Instances of this class are always autocalled diff --git a/IPython/iplib.py b/IPython/iplib.py index 2b21be5..9e1b6c3 100644 --- a/IPython/iplib.py +++ b/IPython/iplib.py @@ -6,7 +6,7 @@ Requires Python 2.3 or newer. This file contains all the classes and helper functions specific to IPython. -$Id: iplib.py 2725 2007-09-07 08:59:10Z vivainio $ +$Id: iplib.py 2746 2007-09-08 14:00:21Z vivainio $ """ #***************************************************************************** @@ -471,7 +471,7 @@ class InteractiveShell(object,Magic): except HomeDirError,msg: fatal(msg) - self.dir_stack = [os.getcwd().replace(self.home_dir,'~')] + self.dir_stack = [] # Functions to call the underlying shell. @@ -1488,6 +1488,8 @@ want to merge them back into the new files.""" % locals() if etype is SyntaxError: self.showsyntaxerror(filename) + elif etype is IPython.ipapi.UsageError: + print "UsageError:", value else: # WARNING: these variables are somewhat deprecated and not # necessarily safe to use in a threaded environment, but tools