[IPython-dev] What To Do With a Problem Like 'cd /'?

Dan Milstein danmil at comcast.net
Wed May 23 11:38:23 EDT 2007


As Ville noted below, subsequent to the prefilter reorg, 'cd /' now  
gives a syntax error, whereas before, it successfully expanded to an  
automagic call.

I've tracked the issue down, but I'm not sure what the proper  
behavior should be.

The problem is that the system is now being far more careful about  
paying attention to possible python operators on a line.  This  
started with a commit by Fernando a month+ ago:

http://projects.scipy.org/ipython/ipython/changeset/2207

This tries to avoid certain bad autocall issues by checking for the  
following chars as the start of the rest of a line, and it finds one,  
just handling the line normally:

'!=()<>+*/%^&|'

Note how '/' is now in there.  When I reorg'd things, I put that  
check in prefilter.checkPythonChars, which gets called *before*  
checkAutomagic.  Thus, when you type:

  : cd /

The system sees the /, and says, basically, "Oh, this looks like it  
might be a valid python expression, so I'm going to just handle it  
normally (and thus not expand the magic cd)".

I'm not sure if this should or should not be 'fixed'.  I mean, OTOH,  
'cd /' is pretty damn useful.  On the other hand, there are some  
weird interactions among the various namespaces, and being  
consistently careful and respectful of possible python operators  
seems like a good, safe practice.

You can work around it with "cd '/'" or "cd \/" (though, ugh).

Or I can maybe special case assignment separately from all the other  
python chars, and only check for that before expanding automagics (so  
that the full pythonChar check just comes before autocall  
expansion).  I *think* that would be safe, but I would not swear to it.

What do people think?

-Dan






On May 21, 2007, at 4:00 AM, Ville M. Vainio wrote:

> On 5/16/07, Dan Milstein <danmil at comcast.net> wrote:
>
>> ...finally ;-)
>>
>> Okay, I just went ahead and committed it to the trunk (r. 2354).
>
> Possible regression: "cd /" now gives syntaxerror, instead of being
> caught as a proper magic command. cd \ and other cd invocations work
> ok.
>
> -- 
> Ville M. Vainio - vivainio.googlepages.com
> blog=360.yahoo.com/villevainio - g[mail | talk]='vivainio'




More information about the IPython-dev mailing list