Issue16430
Created on 2012-11-07 17:00 by Sebastien.Estienne, last changed 2022-04-11 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| re_bug.py | Sebastien.Estienne, 2012-11-07 17:00 | Example of the bug | ||
| Messages (3) | |||
|---|---|---|---|
| msg175109 - (view) | Author: Sebastien Estienne (Sebastien.Estienne) | Date: 2012-11-07 17:00 | |
Hello re.match is blocked and takes 100% cpu forever re_bug.py is an example of the bug. thanx |
|||
| msg175111 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2012-11-07 17:34 | |
There is no a Python bug. You have wrong regexp. Remove "$" at the end or add ".*" before "$". And it would be better if instead of '(?P<date>.*?)\s' and '"(?P<method_uri>.*?)"' you use '(?P<date>\S+)\s' and '"(?P<method_uri>[^"]*)"'. |
|||
| msg175112 - (view) | Author: Mark Dickinson (mark.dickinson) * ![]() |
Date: 2012-11-07 17:35 | |
This is a known issue: there are a good few duplicates in the tracker. Issue #1662581 is one, for example. In this particular case, you can probably fix things by tightening up your regex. Part of the problem is that '.*' is going to match any sequence of characters, including spaces. Judicious use of '\S' to match non-whitespace characters might help. There's not much point to the '?' in '.*?', either. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:57:38 | admin | set | github: 60634 |
| 2012-11-07 17:35:54 | mark.dickinson | set | superseder: the re module can perform poorly: O(2**n) versus O(n**2) messages:
+ msg175112 |
| 2012-11-07 17:34:32 | serhiy.storchaka | set | status: open -> closed nosy:
+ serhiy.storchaka resolution: not a bug |
| 2012-11-07 17:00:35 | Sebastien.Estienne | create | |
