[issue25550] RecursionError in re with '(' * 500

2016-10-16 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Closed as not a bug. Unlike to issue401612 this is not an infinite recursion. Raising RecursionError depends on the context (it is more likely in deeply nested call) and there is a common workaround -- just increase maximum recursion depth using sys.setrecur

[issue25550] RecursionError in re with '(' * 500

2015-11-06 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I think it is possible to make the parser non-recursive, but without reports about such real-world problems it looks premature and just will complicate the code. For years before 3.5 there was a limitation on only 100 capturing groups. -- __

[issue25550] RecursionError in re with '(' * 500

2015-11-06 Thread Terry J. Reedy
Terry J. Reedy added the comment: Is the recursion limit hit enough in real-world problems that we should consider replacing recursive calls and the implicit C call stack with loops and an explicit stack? -- nosy: +terry.reedy ___ Python tracker

[issue25550] RecursionError in re with '(' * 500

2015-11-04 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: re.compile can also raise ValueError and OverflowError. Agree that may be these exceptions can be converted to re.error. But it can also raise MemoryError, and KeyboardInterrupt. And these exceptions can't be converted to re.error. RecursionError is closer

[issue25550] RecursionError in re with '(' * 500

2015-11-04 Thread Florian Bruhin
Florian Bruhin added the comment: I see how it's not possible to compile that pattern as it's using recursion - I don't mind that. However, I think this should be handled and re-raised as a re.error ("Exception raised [...] when some other error occurs during compilation or matching."). I thi

[issue25550] RecursionError in re with '(' * 500

2015-11-04 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: This isn't a bug, this is a limitation of the implementation. Regular expression parser is recursive and Python has a limit for recursion depth. You can increase this limit if needed. >>> import sys, re >>> sys.setrecursionlimit(2000) >>> re.compile('(' * 50

[issue25550] RecursionError in re with '(' * 500

2015-11-04 Thread SilentGhost
Changes by SilentGhost : -- components: +Regular Expressions nosy: +mrabarnett versions: +Python 3.6 ___ Python tracker ___ ___ Python

[issue25550] RecursionError in re with '(' * 500

2015-11-04 Thread Florian Bruhin
New submission from Florian Bruhin: I just found this thanks to Hypothesis[1]: >>> import re >>> re.compile('(' * 500) Traceback (most recent call last): File "", line 1, in File "/usr/lib/python3.5/re.py", line 224, in compile return _compile(pattern, flags)