classification
Title: Regular expressions with empty named groups break isname check
Type: crash Stage: resolved
Components: Regular Expressions Versions: Python 3.2, Python 2.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: "(?P=)" input for Tools/scripts/redemo.py raises unnhandled exception
View: 12759
Assigned To: Nosy List: Gabriel.Rodríguez.Alberich, ezio.melotti, mrabarnett, serhiy.storchaka
Priority: normal Keywords:

Created on 2012-11-29 17:16 by Gabriel.Rodríguez.Alberich, last changed 2012-11-29 17:35 by serhiy.storchaka. This issue is now closed.

Messages (3)
msg176664 - (view) Author: Gabriel Rodríguez Alberich (Gabriel.Rodríguez.Alberich) Date: 2012-11-29 17:16
>>> import re
>>> re.compile("(?P<>)")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/re.py", line 190, in compile
    return _compile(pattern, flags)
  File "/usr/lib/python2.7/re.py", line 240, in _compile
    p = sre_compile.compile(pattern, flags)
  File "/usr/lib/python2.7/sre_compile.py", line 500, in compile
    p = sre_parse.parse(p, flags)
  File "/usr/lib/python2.7/sre_parse.py", line 673, in parse
    p = _parse_sub(source, pattern, 0)
  File "/usr/lib/python2.7/sre_parse.py", line 308, in _parse_sub
    itemsappend(_parse(source, state))
  File "/usr/lib/python2.7/sre_parse.py", line 544, in _parse
    if not isname(name):
  File "/usr/lib/python2.7/sre_parse.py", line 218, in isname
    if not isident(name[0]):
IndexError: string index out of range

isname() shouldn't be blindly accessing name[0].
msg176665 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-11-29 17:30
Fixed in issue12759.
msg176666 - (view) Author: Gabriel Rodríguez Alberich (Gabriel.Rodríguez.Alberich) Date: 2012-11-29 17:32
Uh, sorry about that. Thanks.
History
Date User Action Args
2012-11-29 17:35:09serhiy.storchakasetsuperseder: "(?P=)" input for Tools/scripts/redemo.py raises unnhandled exception
stage: resolved
2012-11-29 17:32:36Gabriel.Rodríguez.Alberichsetresolution: duplicate
2012-11-29 17:32:22Gabriel.Rodríguez.Alberichsetstatus: open -> closed

messages: + msg176666
2012-11-29 17:30:32serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg176665
2012-11-29 17:16:55Gabriel.Rodríguez.Alberichsettitle: Regular expressions with empty named groups breaks isname check -> Regular expressions with empty named groups break isname check
2012-11-29 17:16:26Gabriel.Rodríguez.Alberichcreate