[issue35932] Interpreter gets stuck while applying a compiled regex pattern

2019-02-07 Thread Sateesh Kumar


New submission from Sateesh Kumar :

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 
<https://bugs.python.org/issue35932>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35932] Interpreter gets stuck while applying a regex pattern

2019-02-07 Thread Sateesh Kumar


Sateesh Kumar  added the comment:

@SilentGhost, You are right, when I pass the flag "re.IGNORECASE" for example 
in Variant-2 the python process do gets stuck.  

Here is the revised code for Variant-2:

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

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

Thanks for the correction. I have also modified the title of this issue 
accordingly.

--
title: Interpreter gets stuck while applying a compiled regex pattern -> 
Interpreter gets stuck while applying a regex pattern

___
Python tracker 
<https://bugs.python.org/issue35932>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com