Crash when using multiple capturing groups in re.Scanner (original) (raw)

Bug report

Bug description:

The re.Scanner class crashes with a segmentation fault (memory corruption) when any pattern in the lexicon contains named capturing groups.

import re

lexicon = [ ('(?Pa)(?Pb)', None), # Named capturing groups ]

scanner = re.Scanner(lexicon) result, leftover = scanner.scan("ab") # Segmentation fault occurs here

zsh: segmentation fault python3 test.py

Scanner should process the input normally and return scan results without crashing, but Python interpreter crashes with segmentation fault, indicating memory corruption.

CPython versions tested on:

3.12

Operating systems tested on:

Linux

Linked PRs