[IPython-User] doctest_mode continuation change?

Fernando Perez fperez.net@gmail....
Thu Aug 4 15:39:03 CDT 2011


On Thu, Aug 4, 2011 at 12:35 PM, Matthew Brett <matthew.brett@gmail.com> wrote:
>
> Is there some change that I missed that makes that bad to do?
>

No, you just found a bug, plain and simple...

In fact, supposedly now IPython is smart enough to filter all prompts,
classic or IPython ones, irrespective of %doctest_mode.  And we have
even tests for that :)

Many cases do work:

In [3]: >>> x =1

In [4]: x
Out[4]: 1

In [5]: >>> if x:
   ...:     ...     print 1
   ...:     ...
1

In [6]:

But it looks like our logic fail when there are open data structures
that span multiple lines:

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

So lists and dicts fail, but interestingly, tuples work:

In [7]: >>> a = (1,2,
   ...: 3)

In [8]: a
Out[8]: (1, 2, 3)


In short, it's a bug.  Tracking it here:

https://github.com/ipython/ipython/issues/678

Thanks for the report, and sorry for the hassle, because it will make
doctest handling pretty annoying...

Cheers,

f


More information about the IPython-User mailing list