Skip to content

wrap.py: Fix Python 3.15 compatibility issue with re.Scanner - #773

Merged
daboehme merged 1 commit into
llnl:masterfrom
daboehme:dev/try-fix-wrappy
Oct 12, 2026
Merged

daboehme merged 1 commit into
llnl:masterfrom
daboehme:dev/try-fix-wrappy

Conversation

@daboehme

Copy link
Copy Markdown
Member

Should fix the issue but not tested with Python 3.15 yet.

Here's what Claude says:

Fixed Python 3.15 compatibility issue with re.Scanner by replacing capturing groups with non-capturing groups:

Changes made:

  1. OuterCommentLexer (lines 306-309): Changed (.|[\r\n]) to (?:.|[\r\n]) in the multiline and single-line comment patterns, and ({(?!{)...}) to (?:{(?!{)...}) in the text pattern.

  2. InnerLexer (lines 313-318): Replaced the complex pattern with backreferences (["\'])?((?:(?!\1)[^\\]|\\.)*)\1 with two simpler patterns:

    • r'"(?:[^"\\]|\\.)*"' for double-quoted strings
    • r"'(?:[^'\\]|\\.)*'" for single-quoted strings

    This avoids the backreference \1 which required a capturing group.

Why these changes work:

  • Python 3.15 raised restrictions on re.Scanner to disallow capturing groups since the Scanner API doesn't provide access to captured subgroups anyway
  • Non-capturing groups (?:...) provide the same grouping behavior for alternation and repetition without creating captures
  • The InnerLexer change splits one complex pattern into two simpler ones, which is actually clearer and avoids the backreference entirely

The quoted_id callback function at line 323 will still work correctly because it processes the entire matched token string (with quotes) using re.sub() to strip the quotes.

@daboehme
daboehme merged commit b72ce3f into llnl:master Oct 12, 2026
8 checks passed
@daboehme
daboehme deleted the dev/try-fix-wrappy branch October 12, 2026 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant