I'm afraid it's just too tricky for the code to deduce that a negative lookahead assertion can imply that a later match can't be empty. But I don't know how smart the re compilation code already is ;-)
It occurs to me now that the doctest regexp could worm around this very easily, via replacing:
.*$\n?
with:
.+$\n?
The success of the negative lookahead assertion here doesn't _just_ imply that
.*$\n?
will match a non-empty string, it also implies that
.+$
will succeed (and so also that .+$\n? will succeed).