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

re.VERBOSE doesn't respect whitespace in '( ?P<foo>...)' #61386

Closed
roysmith mannequin opened this issue Feb 11, 2013 · 2 comments
Closed

re.VERBOSE doesn't respect whitespace in '( ?P<foo>...)' #61386

roysmith mannequin opened this issue Feb 11, 2013 · 2 comments
Labels
stdlib Python modules in the Lib dir topic-regex type-bug An unexpected behavior, bug, or error

Comments

@roysmith
Copy link
Mannequin

roysmith mannequin commented Feb 11, 2013

BPO 17184
Nosy @ezio-melotti
Superseder
  • bpo-15606: re.VERBOSE whitespace behavior not completely documented
  • 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 2013-02-15.21:08:18.721>
    created_at = <Date 2013-02-11.19:39:08.799>
    labels = ['expert-regex', 'type-bug', 'library']
    title = "re.VERBOSE doesn't respect whitespace in '( ?P<foo>...)'"
    updated_at = <Date 2013-02-15.21:08:18.719>
    user = 'https://bugs.python.org/roysmith'

    bugs.python.org fields:

    activity = <Date 2013-02-15.21:08:18.719>
    actor = 'ezio.melotti'
    assignee = 'none'
    closed = True
    closed_date = <Date 2013-02-15.21:08:18.721>
    closer = 'ezio.melotti'
    components = ['Library (Lib)', 'Regular Expressions']
    creation = <Date 2013-02-11.19:39:08.799>
    creator = 'roysmith'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 17184
    keywords = []
    message_count = 2.0
    messages = ['181927', '181931']
    nosy_count = 3.0
    nosy_names = ['roysmith', 'ezio.melotti', 'mrabarnett']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '15606'
    type = 'behavior'
    url = 'https://bugs.python.org/issue17184'
    versions = ['Python 2.7', 'Python 3.2', 'Python 3.3', 'Python 3.4']

    @roysmith
    Copy link
    Mannequin Author

    roysmith mannequin commented Feb 11, 2013

    # Python 2.7.3
    # Ubuntu 12.04

    import re
    pattern = r"( ?P<phrase>.*)"
    regex = re.compile(pattern, re.VERBOSE)

    The above raises an exception in re.compile():

    Traceback (most recent call last):
      File "./try.py", line 6, in <module>
        regex = re.compile(pattern, re.VERBOSE)
      File "/home/roy/env/python/lib/python2.7/re.py", line 190, in compile
        return _compile(pattern, flags)
      File "/home/roy/env/python/lib/python2.7/re.py", line 242, in _compile
        raise error, v # invalid expression
    sre_constants.error: nothing to repeat

    The problem appears to be that re.VERBOSE isn't ignoring the space after the "(".

    Maybe this is a duplicate of bpo-15606 ?

    @roysmith roysmith mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Feb 11, 2013
    @mrabarnett
    Copy link
    Mannequin

    mrabarnett mannequin commented Feb 11, 2013

    It does look like a duplicate to me.

    @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
    stdlib Python modules in the Lib dir topic-regex type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant