You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix trailing text in doctest-syntax plot_directive.
The problem was that an input like
```
Some text.
>>> python_code()
The end.
```
would get split to
```
Some text.
>>> python_code()
```
and
```
The end.
```
and that unescape_doctest would then believe that `The end.` is already
python code (as it doesn't contain a `>>>`) and try to run it as is.
To fix this, instead of repeatedly calling `contains_doctest` everywhere
to guess whether fragments are doctest or python, just do it once at the
beginning, do the escaping once if needed at the beginning and then call
the new _functions (`_split_code_at_show`, `_run_code`) which don't try to
guess anymore. Because of the new (non-guessing) semantics these must
go to new functions, so let's make them private and just deprecate the old
(public) ones.
The escaping itself was done by `unescape_doctest`, but that had a
separate bug misparsing
```
This is an example...
>>> some_python()
... isn't it?
```
the last line would get incorrectly misparsed as a line continuation,
despite the blank line in between. Instead of trying to fix that
ourselves, just use `doctest.script_from_examples` which exactly serves
that purpose.
0 commit comments