diff --git a/IPython/Extensions/pspersistence.py b/IPython/Extensions/pspersistence.py index b293cca..6dfc29e 100644 --- a/IPython/Extensions/pspersistence.py +++ b/IPython/Extensions/pspersistence.py @@ -20,7 +20,8 @@ def restore_aliases(self): staliases = ip.db.get('stored_aliases', {}) for k,v in staliases.items(): #print "restore alias",k,v # dbg - self.alias_table[k] = v + #self.alias_table[k] = v + ip.defalias(k,v) def refresh_variables(ip): diff --git a/IPython/Magic.py b/IPython/Magic.py index be6fd13..f9d9fc4 100644 --- a/IPython/Magic.py +++ b/IPython/Magic.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """Magic functions for InteractiveShell. -$Id: Magic.py 2607 2007-08-13 13:25:24Z fperez $""" +$Id: Magic.py 2637 2007-08-17 16:18:05Z vivainio $""" #***************************************************************************** # Copyright (C) 2001 Janko Hauser and @@ -2289,7 +2289,11 @@ Defaulting color scheme to 'NoColor'""" res = [] showlast = [] for alias in aliases: - tgt = atab[alias][1] + try: + tgt = atab[alias][1] + except TypeError: + # unsubscriptable? probably a callable + tgt = atab[alias] # 'interesting' aliases if (alias in stored or alias.lower() != os.path.splitext(tgt)[0].lower() or diff --git a/IPython/ipapi.py b/IPython/ipapi.py index d4a5aec..36256b8 100644 --- a/IPython/ipapi.py +++ b/IPython/ipapi.py @@ -362,13 +362,12 @@ class IPApi: setattr(IPython.shadowns, name,cmd) return - - nargs = cmd.count('%s') - if nargs>0 and cmd.find('%l')>=0: - raise Exception('The %s and %l specifiers are mutually exclusive ' - 'in alias definitions.') + if isinstance(cmd,basestring): + nargs = cmd.count('%s') + if nargs>0 and cmd.find('%l')>=0: + raise Exception('The %s and %l specifiers are mutually exclusive ' + 'in alias definitions.') - else: # all looks OK self.IP.alias_table[name] = (nargs,cmd) def defmacro(self, *args): diff --git a/IPython/iplib.py b/IPython/iplib.py index 735bc0c..a848ae1 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 2631 2007-08-15 07:07:36Z fperez $ +$Id: iplib.py 2637 2007-08-17 16:18:05Z vivainio $ """ #***************************************************************************** @@ -1742,7 +1742,10 @@ want to merge them back into the new files.""" % locals() def transform_alias(self, alias,rest=''): """ Transform alias to system command string. """ - nargs,cmd = self.alias_table[alias] + trg = self.alias_table[alias] + + nargs,cmd = trg + # print trg #dbg if ' ' in cmd and os.path.isfile(cmd): cmd = '"%s"' % cmd