New submission from Sateesh Kumar <sateeshkum...@gmail.com>:
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. ---------- files: gdb_trace messages: 335029 nosy: Sateesh Kumar priority: normal severity: normal status: open title: Interpreter gets stuck while applying a compiled regex pattern type: crash versions: Python 2.7 Added file: https://bugs.python.org/file48110/gdb_trace _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue35932> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com