[issue18647] re.error: nothing to repeat

Serhiy Storchaka report at bugs.python.org
Sun Aug 4 20:31:38 CEST 2013


Serhiy Storchaka added the comment:

> Serhiy, I don't see the regexp '(?:.*$\n?)*' anywhere in doctest.py.  Are you talking about the _EXAMPLE_RE regexp?  That's the closest I see.

Yes, it is. In my previous message I answered Eli.

> If that's the case, the "nothing to repeat" error is incorrect:  _EXAMPLE_RE also contains a negative lookahead assertion '(?![ ]*$)' to ensure that the later '.*$\n?' part never tries to match an empty string.

Thank you for explanation. Unlucky the getwidth() method is not smart enough to detect that minimal length of matched string is not 0. We should made either the getwidth() method or the _simple() function (or both) more smart.

> A compromise may be to replace
> .*$\n?
> with
> .+$\n? | .*$\n

I'm sure similar patterns are used in third-party code. We shouldn't break them, therefore we should fix _simple()/getwidth().

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18647>
_______________________________________


More information about the Python-bugs-list mailing list