[IPython-dev] IPython bug?

Gary Bishop gb at cs.unc.edu
Sat May 24 08:46:18 EDT 2003

On Fri, 23 May 2003 20:33:21 -0600 "Fernando Perez" 
<fperez at colorado.edu> wrote:
>>> FWIW, if I type something similar in Linux, there's no problem.  So it 
>>> _might_ be a readline issue, perhaps.

It *has* to happen on Linux. Try:

In [1]: @cd foo\<RET>

I bet you'll get the never ending prompt. The problem starts in 
iplib.py line 1085 where you convert the input into a parameter:

            return shell+scommand+'(parameter_s="""%s""")' % (parameter_s,)

If parameter_s ends with a \ then it escapes one of the triple quotes! 
So the string doesn't end... Pretty twisted. Reverse slash is a sick, 
sick character.

Seems to me that at the point you go from a typed line to a string 
parameter you have to take care to escape \ and possibly other characters.

This patch appears to fix the immediate problem:

$ diff -Naur iplib.py~ iplib.py
--- iplib.py~   2003-05-21 06:09:54.000000000 -0400
+++ iplib.py    2003-05-24 08:43:49.000000000 -0400
@@ -1082,6 +1082,7 @@
                 parameter_s = ' ' + parameter_s
             if parameter_s.endswith('"'):
                 parameter_s += ' '
+            parameter_s = parameter_s.replace('\\', '\\\\')
             return shell+scommand+'(parameter_s="""%s""")' % (parameter_s,)
             return shell+line+'()'


More information about the IPython-dev mailing list