diff --git a/IPython/Magic.py b/IPython/Magic.py index 3f132dd..03730e6 100644 --- a/IPython/Magic.py +++ b/IPython/Magic.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """Magic functions for InteractiveShell. -$Id: Magic.py 1092 2006-01-27 23:56:32Z vivainio $""" +$Id: Magic.py 1094 2006-01-28 00:47:41Z vivainio $""" #***************************************************************************** # Copyright (C) 2001 Janko Hauser and @@ -33,7 +33,7 @@ import time import cPickle as pickle import textwrap from cStringIO import StringIO -from getopt import getopt +from getopt import getopt,GetoptError from pprint import pprint, pformat # profile isn't bundled by default in Debian for license reasons @@ -306,7 +306,11 @@ license. To use profiling, please install"python2.3-profiler" from non-free.""") # need to look for options argv = shlex_split(arg_str) # Do regular option processing - opts,args = getopt(argv,opt_str,*long_opts) + try: + opts,args = getopt(argv,opt_str,*long_opts) + except GetoptError,e: + raise GetoptError('%s ( allowed: "%s" %s)' % (e.msg,opt_str, + " ".join(long_opts))) for o,a in opts: if o.startswith('--'): o = o[2:] diff --git a/doc/ChangeLog b/doc/ChangeLog index f936d3b..a938a1c 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -27,6 +27,10 @@ * usage.py, Magic.py: added %quickref * iplib.py: ESC_PAREN fixes: /f 1 2 -> f(1,2), not f(1 2). + + * GetoptErrors when invoking magics etc. with wrong args + are now more helpful: + GetoptError: option -l not recognized (allowed: "qb" ) 2006-01-25 Fernando Perez