[issue30973] Regular expression "hangs" interpreter

2017-07-20 Thread Matthew Barnett
Matthew Barnett added the comment: The regex module is much better in this respect, but it's not foolproof. With this particular example it completes quickly. -- ___ Python tracker

[issue30973] Regular expression "hangs" interpreter

2017-07-20 Thread R. David Murray
R. David Murray added the comment: Right. We don't try to fix handling these kinds of exponential expressions. This is a case of "don't do that" :) (I don't know if the regex module is better at "handling" this kind of regex bug.) -- nosy: +r.david.murray resolution: -> wont fix st

[issue30973] Regular expression "hangs" interpreter

2017-07-20 Thread Gareth Rees
Gareth Rees added the comment: This is the usual exponential backtracking behaviour of Python's regex engine. The problem is that the regex (?:[^*]+|\*[^/])* can match against a string in exponentially many ways, and Python's regex engine tries all of them before giving up. -- no

[issue30973] Regular expression "hangs" interpreter

2017-07-19 Thread T Trindad
New submission from T Trindad: The following code "hangs" the interpreter: import re re.search(r"/\*\*((?:[^*]+|\*[^/])*)\*/", """ /** Copy Constructor **/ private EvaluationContext (EvaluationContext base) {""") Changing the regex to r"/\*\*((?:[^*]|\*[^/])*)\*/" makes