Skip to content
This repository

partial fix for issue #678 #877

merged 2 commits into from over 2 years ago

3 participants

Daniel Velkov Thomas Kluyver Fernando Perez
Daniel Velkov
djv commented October 14, 2011

partial fix for issue #678

The patch handles the case of:

In [4]: >>> a = [1,
   ...: ... 2]

In [5]: a
Out[5]: [1, 2]

but not

In [3]: >>> a = [1
   ...: ... ,2]
  File "<ipython-input-3-5b39dccea2ae>", line 2
    ... ,2]
SyntaxError: invalid syntax

which happens to be valid in python.

Thomas Kluyver

Thanks, Daniel. At a glance, that looks sensible, and I don't think I've seen any examples where the comma is after the newline, so that's probably not a big concern.

Just to note: we prefer if you don't merge master back into feature branches, since it complicates the commit graph. In general, it should be fine to just make the change and leave it until it's merged into master. If it ends up unable to merge cleanly, you can rebase it, do a forced push, and make a note on the pull request that you've done that.

Fernando Perez

@djv, let us know if you need a hand with the rebasing, so that your pull request contains only the intended changes and not master.

Daniel Velkov
djv commented October 17, 2011

OK, I removed the commit with the merge.

Fernando Perez

Great, that's better. Now, the fix looks good, but in all such cases it's a good idea to add also a test that fails when the fix is not in place but passes once the fix is in. This will ensure that the problem doesn't recur in the future. You don't need to write up a new file, you can simply add a new test to the existing

With a small test as indicated above, this will be good to go. Thanks a lot!

Daniel Velkov
djv commented October 18, 2011

Added one test which exposes the bug.
Is there a way to run all tests for IPython? The wiki says that import IPython; IPython.test() should do it, but it doesn't run any of the tests from I had to do python -m unittest IPython.core.tests.test_inputsplitter

Fernando Perez

Sorry, that's a lie in the wiki. Can you point me to where you found it so I can fix it? The way to run the tests is via


which is a wrapper around nosetests. You can pass any nose flag

iptest -vvs

is my standard way of running it; and you can run specific subtests:

iptest -vvs IPython.core.tests.test_inputsplitter:test_spaces

runs only the test_spaces function.

Daniel Velkov
djv commented October 18, 2011

It's at I tried iptest as you suggested and it doesn't seem to go through IPython.core.tests.test_inputsplitter.

Fernando Perez
Fernando Perez
Daniel Velkov
djv commented October 18, 2011

The only way I could make it work is by running python develop. After that iptest is doing the right thing.

Fernando Perez
Fernando Perez fperez merged commit 5ffaa56 into from October 18, 2011
Fernando Perez fperez closed this October 18, 2011
Fernando Perez

Merged after a small fixup for clarity/optim at the end. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 2 unique commits by 1 author.

Oct 14, 2011
fix for broken input prompt stripping with multiline data structures …
…(issue #678)
Oct 18, 2011
added test for issue #678 5ffaa56
This page is out of date. Refresh to see the latest.
3  IPython/core/
@@ -760,7 +760,8 @@ def push(self, lines):
760 760
             push = super(IPythonInputSplitter, self).push
761 761
             for line in lines_list:
762 762
                 if self._is_complete or not self._buffer or \
-                   (self._buffer and self._buffer[-1].rstrip().endswith(':')):
+                   (self._buffer and (self._buffer[-1].rstrip().endswith(':') or\
+                     self._buffer[-1].rstrip().endswith(','))):
764 765
                     for f in transforms:
765 766
                         line = f(line)
766 767
6  IPython/core/tests/
@@ -534,6 +534,12 @@ def transform_checker(tests, func):
534 534
           ('   ....: ', ''),
535 535
536 536
+       multiline_datastructure =
+       [ [('>>> a = [1,','a = [1,'),
+          ('... 2]','2]'),
+         ],
+       ],
537 543
538 544
539 545

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.