Author tim.peters
Recipients kleshni, nedbat, tim.peters
Date 2020-05-11.21:24:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1589232260.88.0.824584539834.issue40480@roundup.psfhosted.org>
In-reply-to
Content
Ned, would it be possible to rewrite code of the form:

    if giant pasted regexp matches:
    
to:

    if any(p matches for p in patterns):

That should work under any version of Python.

There's no guarantee that regexps _can_ be pasted together and still work, so I can't call this change "a bug".  That pasting regexps together "worked" before was an implementation accident.

I'd be happy to change it anyway, except I know of no way to use Python's re engine without backreferences that can avoid exponential-time behavior in some cases.  In some other regexp engines, yes (e.g., as the code comments note, in those that support "atomic grouping"), but not in Python's.  Nor does Python's re engine support reusing backreference names or numbers.

So I know of no way to restore the ability to paste regexps together that wouldn't reintroduce the possiblity of exponential time failure :-(
History
Date User Action Args
2020-05-11 21:24:21tim.peterssetrecipients: + tim.peters, nedbat, kleshni
2020-05-11 21:24:20tim.peterssetmessageid: <1589232260.88.0.824584539834.issue40480@roundup.psfhosted.org>
2020-05-11 21:24:20tim.peterslinkissue40480 messages
2020-05-11 21:24:20tim.peterscreate