[issue23541] Re module's match() fails to halt on a particular input

2015-03-02 Thread Serhiy Storchaka
Changes by Serhiy Storchaka storch...@gmail.com: -- resolution: - wont fix stage: - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23541 ___

[issue23541] Re module's match() fails to halt on a particular input

2015-02-27 Thread Ceridwen
New submission from Ceridwen: Attached is a three-line script whose third line, a call to match() for a compiled regex, fails to halt on Python 2.7 and on 3.4 (after changing ur in front of the regex string to r to accommodate the change in Unicode handling). I found it by stepping through

[issue23541] Re module's match() fails to halt on a particular input

2015-02-27 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Minimal example for your case is re.match(r'(\w+\s*)+\s+\d+', 'Compiling Regular Patterns to Sequential Machines') It doesn't halt, it just needs too long time to finish. Your should rewrite the regular expression to avoid catastrophic backtracking

[issue23541] Re module's match() fails to halt on a particular input

2015-02-27 Thread Matthew Barnett
Matthew Barnett added the comment: The problem is with the (\w+\s*)+. \s* can match an empty string, so when matching a word it's like (\w+)+. If you have n letters, there are 2**n ways it could match, and if what follows never matches, it'll try all of them. It _will_ finish, eventually...