Skip to content

Error compiling valid regex #50406

Closed
Closed

Description

@eloff
mannequin
BPO 6156
Nosy @birkenfeld, @ezio-melotti, @serhiy-storchaka
Superseder
  • bpo-2636: Adding a new regex module (compatible with re)
  • Files
  • test_re.py.patch: patch for Lib/test/test_re.py
  • sre_compile.py.patch: patch for Lib/sre_compile.py
  • 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 2010-07-29.17:47:04.141>
    created_at = <Date 2009-05-31.16:26:01.022>
    labels = ['type-bug', 'library']
    title = 'Error compiling valid regex'
    updated_at = <Date 2017-11-19.19:44:16.097>
    user = 'https://bugs.python.org/Eloff'

    bugs.python.org fields:

    activity = <Date 2017-11-19.19:44:16.097>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2010-07-29.17:47:04.141>
    closer = 'georg.brandl'
    components = ['Library (Lib)']
    creation = <Date 2009-05-31.16:26:01.022>
    creator = 'Eloff'
    dependencies = []
    files = ['14141', '14142']
    hgrepos = []
    issue_num = 6156
    keywords = ['patch']
    message_count = 8.0
    messages = ['88600', '88605', '88646', '88649', '88662', '88667', '111980', '306512']
    nosy_count = 6.0
    nosy_names = ['georg.brandl', 'Eloff', 'ezio.melotti', 'mrabarnett', 'crchemist', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'out of date'
    stage = None
    status = 'closed'
    superseder = '2636'
    type = 'behavior'
    url = 'https://bugs.python.org/issue6156'
    versions = ['Python 2.6', 'Python 3.0']

    Activity

    1. eloff commented on May 31, 2009

      eloffmannequin
      MannequinAuthor

      This works:

      r'([xy])(?:\1)+'

      This won't compile, "error: nothing to repeat"

      r'([xy])(?:\s*\1)+'

      I can execute this under other regex engines, and it seems to me that it
      really should work.

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      type-bugAn unexpected behavior, bug, or error
      on May 31, 2009
    3. mrabarnett commented on May 31, 2009

      mrabarnettmannequin
      Mannequin

      I agree that it's a bug.

      A workaround is r'([xy])(?:\s{0,65534}\1)+'. A repeat of 65535 is
      treated as unlimited (but no warning is given).

    4. crchemist commented on Jun 1, 2009

      crchemistmannequin
      Mannequin

      tests for this issue.

    5. crchemist commented on Jun 1, 2009

      crchemistmannequin
      Mannequin

      patch that fix this

    6. birkenfeld commented on Jun 1, 2009

      @birkenfeld
      Member

      Just taking out the "raise" seems questionable to me; are you sure there
      are no valid errors that can be caught there?

    7. crchemist commented on Jun 1, 2009

      crchemistmannequin
      Mannequin
    8. birkenfeld commented on Jul 29, 2010

      @birkenfeld
      Member

      Closing in favor of bpo-2636, which allows this regex to be compiled.

    9. serhiy-storchaka commented on Nov 19, 2017

      @serhiy-storchaka
      Member

      This issue was fixed in bpo-9179.

      The issue with 65535 repeats was fixed in bpo-13169.

    10. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions