Skip to content

ValueError: Cannot use capturing groups in re.Scanner on Python 3.15 #149

@yunzheng

Description

@yunzheng

When running the tests on Python 3.15 it breaks on:

tests/test_align.py:23:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
dissect/cstruct/cstruct.py:267: in load
    TokenParser(self, **kwargs).parse(definition)
dissect/cstruct/parser.py:436: in parse
    scanner = re.Scanner(self.TOK.tokens)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <re.Scanner object at 0x10b73ef90>
lexicon = [('#\\[(?P<values>[^\\]]+)\\](?=\\s*)', <function TokenCollection.add.<locals>.<lambda> at 0x10b9e33d0>), ('#define\\s...locals>.<lambda> at 0x10b9e3690>), ('#else\\s*', <function TokenCollection.add.<locals>.<lambda> at 0x10b9e3740>), ...]
flags = 0

    def __init__(self, lexicon, flags=0):
        from ._constants import BRANCH, SUBPATTERN
        if isinstance(flags, RegexFlag):
            flags = flags.value
        self.lexicon = lexicon
        # combine phrases into a compound pattern
        p = []
        s = _parser.State()
        s.flags = flags
        for phrase, action in lexicon:
            sub_pattern = _parser.parse(phrase, flags)
            if sub_pattern.state.groups != 1:
>               raise ValueError("Cannot use capturing groups in re.Scanner")
E               ValueError: Cannot use capturing groups in re.Scanner

../../.local/share/uv/python/cpython-3.15.0a2-macos-aarch64-none/lib/python3.15/re/__init__.py:402: ValueError

How to reproduce:

uv run -p 3.15 pytest -x

Exact Python version is: Python 3.15.0a2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions