Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regular expressions with empty named groups break isname check #60782

Closed
GabrielRodrguezAlberich mannequin opened this issue Nov 29, 2012 · 3 comments
Closed

Regular expressions with empty named groups break isname check #60782

GabrielRodrguezAlberich mannequin opened this issue Nov 29, 2012 · 3 comments
Labels
topic-regex type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@GabrielRodrguezAlberich
Copy link
Mannequin

BPO 16578
Nosy @ezio-melotti, @serhiy-storchaka
Superseder
  • bpo-12759: "(?P=)" input for Tools/scripts/redemo.py raises unnhandled exception
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2012-11-29.17:32:22.052>
    created_at = <Date 2012-11-29.17:16:26.267>
    labels = ['expert-regex', 'type-crash']
    title = 'Regular expressions with empty named groups break isname check'
    updated_at = <Date 2012-11-29.17:35:09.963>
    user = 'https://bugs.python.org/GabrielRodrguezAlberich'

    bugs.python.org fields:

    activity = <Date 2012-11-29.17:35:09.963>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2012-11-29.17:32:22.052>
    closer = 'Gabriel.Rodr\xc3\xadguez.Alberich'
    components = ['Regular Expressions']
    creation = <Date 2012-11-29.17:16:26.267>
    creator = 'Gabriel.Rodr\xc3\xadguez.Alberich'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 16578
    keywords = []
    message_count = 3.0
    messages = ['176664', '176665', '176666']
    nosy_count = 4.0
    nosy_names = ['ezio.melotti', 'mrabarnett', 'serhiy.storchaka', 'Gabriel.Rodr\xc3\xadguez.Alberich']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '12759'
    type = 'crash'
    url = 'https://bugs.python.org/issue16578'
    versions = ['Python 2.7', 'Python 3.2']

    @GabrielRodrguezAlberich
    Copy link
    Mannequin Author

    >>> 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].

    @GabrielRodrguezAlberich GabrielRodrguezAlberich mannequin added topic-regex type-crash A hard crash of the interpreter, possibly with a core dump labels Nov 29, 2012
    @GabrielRodrguezAlberich GabrielRodrguezAlberich mannequin changed the title Regular expressions with empty named groups breaks isname check Regular expressions with empty named groups break isname check Nov 29, 2012
    @serhiy-storchaka
    Copy link
    Member

    Fixed in bpo-12759.

    @GabrielRodrguezAlberich
    Copy link
    Mannequin Author

    Uh, sorry about that. Thanks.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    topic-regex type-crash A hard crash of the interpreter, possibly with a core dump
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant