[issue36714] Tweak doctest 'example' regex to allow a leading ellipsis in 'want' line

Brian Skinn report at bugs.python.org
Fri Apr 26 10:10:22 EDT 2019


Brian Skinn <bskinn at alum.mit.edu> added the comment:

Ahh, this *will* break some doctests: any with blank PS2 lines in the 'source' portion without the explicit trailing space:

1] >>> def foo():
2] ...    print("bar")
3] ...
4] ...    print("baz")
5] >>> foo()
6] bar
7] baz

If line 3 contains exactly "..." instead of starting with "... ", it will not be recognized as a PS2 line and the example will be parsed as:

'source'
>>> def foo():
...    print("bar")

'want'
...
...    print("baz")

IMO this isn't a *terribly* unreasonable tradeoff, though -- it would enable the specific ellipsis use-case as in the OP, at the cost of breaking some doctests, which shouldn't(?) be in any critical paths?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36714>
_______________________________________


More information about the Python-bugs-list mailing list