Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

multiline strings at end of input cause noop #306

Closed
ivanov opened this Issue · 5 comments

3 participants

@ivanov
Owner

Overview

Triple-quoted strings cause expressions before or after it to be ignored and not executed (in both qtconsole and terminal)

Note how the error from In[2] is suppressed, and expression in In[3] not
evaluated in trunk, whereas the desired behavior occurred in 0.10.2.

trunk behavior:

In [1]: a
NameError                                 Traceback (most recent call last)
/home/pi/ in ()
----> 1 a
NameError: name 'a' is not defined
In [2]: a;"""
   ...: """

In [3]: a=10;"""
   ...: """

In [4]: a
NameError                                 Traceback (most recent call last)
/home/pi/ in ()
----> 1 a

NameError: name 'a' is not defined

0.10.2 behavior

In [1]: a
NameError                                 Traceback (most recent call last)
/home/pi/ in ()
NameError: name 'a' is not defined

In [2]: a;"""
   ...: """
NameError                                 Traceback (most recent call last)
/home/pi/ in ()
NameError: name 'a' is not defined

In [3]: a=10;"""
   ...: """
Out[3]: '\n'

In [4]: a
Out[4]: 10
@fperez
Owner

Thanks for the report, Paul. This is most certainly a bug in core.inputsplitter. Fortunately it's easy to write a clean test for it, I'm not quite sure what the actual fix is quite yet though.

@ivanov
Owner

test for this bug is in trunk as of 94644f8. You will find it in the file IPython/core/tests/test_interactiveshell.py - please remove the skip_known_failure decorator to work on this bug.

@takluyver
Owner

This might be a result of my switch to using ast instead of compiler. Our own inputsplitter gets it right, but then we rejoin it and split it again based on ast. That gives us the two lines as separate blocks, neither of which is valid.

@takluyver
Owner

This is fixed in my ast-splitter branch: https://github.com/takluyver/ipython/commits/ast-splitter

@takluyver
Owner

Enable test for cells ending in multiline strings, as it now passes.

Closed by 4863c51

@takluyver takluyver closed this
@markvoorhies markvoorhies referenced this issue from a commit in markvoorhies/ipython
@ivanov ivanov added test for GH-306 1a81d3e
@ellisonbg ellisonbg referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@ellisonbg ellisonbg referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@ivanov ivanov referenced this issue from a commit in ivanov/ipython
@ivanov ivanov added test for GH-306 c8e0102
@mattvonrocketstein mattvonrocketstein referenced this issue from a commit in mattvonrocketstein/ipython
@ivanov ivanov added test for GH-306 69509ee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.