➜

This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Sateesh Kumar
Recipients Sateesh Kumar
Date 2019-02-07.17:33:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1549560807.38.0.703809508219.issue35932@roundup.psfhosted.org>
In-reply-to
Content
The python interpreter gets stuck while applying a compiled regex pattern against a given string.

The regex matching doesn't get stuck if uncompiled regex pattern is used, or if the flag "re.IGNORECASE" is not used for regex match. 

Below code snippets gives more details.

* Variant-1
# Python process gets stuck

~/workbench$ cat match.py 
import re
pattern = "^[_a-z0-9-]+([\.'_a-z0-9-]+)*@[a-z0-9]+([\.a-z0-9-]+)*(\.[a-z]{2,4})$"
compiled_pattern = re.compile(pattern, re.IGNORECASE)
val = "Z230-B900_X-Suite_Migration_Shared_Volume"
re.match(compiled_pattern, val)

~/workbench$ python match.py 
^^^ The interpreter gets stuck.

* Variant-2 (Using uncompiled pattern) 
# python interpreter doesn't get stuck

~/workbench$ cat match.py
import re
pattern = "^[_a-z0-9-]+([\.'_a-z0-9-]+)*@[a-z0-9]+([\.a-z0-9-]+)*(\.[a-z]{2,4})$"
compiled_pattern = re.compile(pattern, re.IGNORECASE)
val = "Z230-B900_X-Suite_Migration_Shared_Volume"
re.match(pattern, val)

* Variant-3 (Using compiled pattern, but without flag re.IGNORECASE)
# Python interpreter doesn't get stuck

~/workbench$ cat match.py
import re
pattern = "^[_a-z0-9-]+([\.'_a-z0-9-]+)*@[a-z0-9]+([\.a-z0-9-]+)*(\.[a-z]{2,4})$"
compiled_pattern = re.compile(pattern)
val = "Z230-B900_X-Suite_Migration_Shared_Volume"
re.match(compiled_pattern, val)

# Platform details
~/workbench$ python -V
Python 2.7.12

~/workbench$ uname -a
Linux ubuntu16-template 4.4.0-59-generic #80-Ubuntu SMP Fri Jan 6 17:47:47 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

Though above details are from Python/2.7 I see similar beahviour with Python/3.5.2 too.
History
Date User Action Args
2019-02-07 17:33:31Sateesh Kumarsetrecipients: + Sateesh Kumar
2019-02-07 17:33:27Sateesh Kumarsetmessageid: <1549560807.38.0.703809508219.issue35932@roundup.psfhosted.org>
2019-02-07 17:33:27Sateesh Kumarlinkissue35932 messages
2019-02-07 17:33:27Sateesh Kumarcreate