diff --git a/IPython/Magic.py b/IPython/Magic.py index b725149..489b460 100644 --- a/IPython/Magic.py +++ b/IPython/Magic.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """Magic functions for InteractiveShell. -$Id: Magic.py 2104 2007-02-20 10:25:51Z fperez $""" +$Id: Magic.py 2122 2007-03-01 02:27:11Z fperez $""" #***************************************************************************** # Copyright (C) 2001 Janko Hauser and @@ -210,6 +210,7 @@ license. To use profiling, please install"python2.3-profiler" from non-free.""") except KeyError: continue else: + #print 'oname_rest:', oname_rest # dbg for part in oname_rest: try: parent = obj diff --git a/IPython/iplib.py b/IPython/iplib.py index 607d36c..0d0949f 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 2014 2007-01-05 10:36:58Z fperez $ +$Id: iplib.py 2122 2007-03-01 02:27:11Z fperez $ """ #***************************************************************************** @@ -492,6 +492,15 @@ class InteractiveShell(object,Magic): r'([\?\w\.]+\w*\s*)' r'(\(?.*$)') + # A simpler regexp used as a fallback if the above doesn't work. This + # one is more conservative in how it partitions the input. This code + # can probably be cleaned up to do everything with just one regexp, but + # I'm afraid of breaking something; do it once the unit tests are in + # place. + self.line_split_fallback = re.compile(r'^(\s*)' + r'([\w\.]*)' + r'(.*)') + # Original re, keep around for a while in case changes break something #self.line_split = re.compile(r'(^[\s*!\?%,/]?)' # r'(\s*[\?\w\.]+\w*\s*)' @@ -2017,17 +2026,14 @@ want to merge them back into the new files.""" % locals() lsplit = self.line_split.match(line) if lsplit is None: # no regexp match returns None - try: - iFun,theRest = line.split(None,1) - except ValueError: - iFun,theRest = line,'' - pre = re.match('^(\s*)(.*)',line).groups()[0] - else: - pre,iFun,theRest = lsplit.groups() + lsplit = self.line_split_fallback.match(line) + #pre,iFun,theRest = lsplit.groups() # dbg #print 'line:<%s>' % line # dbg #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg - return pre,iFun.strip(),theRest + #return pre,iFun.strip(),theRest # dbg + + return lsplit.groups() def _prefilter(self, line, continue_prompt): """Calls different preprocessors, depending on the form of line.""" diff --git a/doc/ChangeLog b/doc/ChangeLog index b7f038d..b1a729b 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,9 @@ +2007-02-28 Fernando Perez + + * IPython/iplib.py (split_user_input): fix input splitting so we + don't attempt attribute accesses on things that can't possibly be + valid Python attributes. After a bug report by Alex Schmolck. + 2007-02-27 Fernando Perez * IPython/Shell.py (IPShellGTK.mainloop): update threads calls to