Bug 2433805 - cmakelang fails to build with Python 3.15: ValueError: Cannot use capturing groups in re.Scanner and multiple AssertionErrors
Summary: cmakelang fails to build with Python 3.15: ValueError: Cannot use capturing g...
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: cmakelang
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Christoph Erhardt
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.15
TreeView+ depends on / blocked
 
Reported: 2026-01-28 13:19 UTC by Karolina Surma
Modified: 2026-02-07 23:41 UTC (History)
3 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2026-02-07 23:41:20 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Karolina Surma 2026-01-28 13:19:05 UTC
cmakelang fails to build with Python 3.15.0a5.

An example of a failing test, there is a bunch of those:

ERROR: test_string_with_quotes (cmakelang.lex.tests.TestSpecificLexings.test_string_with_quotes)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/cmakelang-0.6.13-build/cmake_format-0.6.13/cmakelang/lex/tests.py", line 59, in test_string_with_quotes
    self.assert_tok_types(r"""
    ~~~~~~~~~~~~~~~~~~~~~^^^^^
      "this is a \"string"
      ^^^^^^^^^^^^^^^^^^^^
      """, [TokenType.NEWLINE, TokenType.WHITESPACE, TokenType.QUOTED_LITERAL,
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            TokenType.NEWLINE, TokenType.WHITESPACE])
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/cmakelang-0.6.13-build/cmake_format-0.6.13/cmakelang/lex/tests.py", line 19, in assert_tok_types
    [tok.type for tok in lex.tokenize(input_str)])
                         ~~~~~~~~~~~~^^^^^^^^^^^
  File "/builddir/build/BUILD/cmakelang-0.6.13-build/cmake_format-0.6.13/cmakelang/lex/__init__.py", line 135, in tokenize
    scanner = re.Scanner([
        # double quoted string
    ...<48 lines>...
         lambda s, t: (TokenType.UNQUOTED_LITERAL, t)),
    ], re.DOTALL)
  File "/usr/lib64/python3.15/re/__init__.py", line 402, in __init__
    raise ValueError("Cannot use capturing groups in re.Scanner")
ValueError: Cannot use capturing groups in re.Scanner

Another example of AssertionError (multiple similar happen):

FAIL: test_require_valid (cmakelang.format.invocation_tests.TestInvocations.test_require_valid)
Verify that the --require-valid-layout flag works as intended
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/cmakelang-0.6.13-build/cmake_format-0.6.13/cmakelang/format/invocation_tests.py", line 354, in test_require_valid
    self.assertEqual(0, statuscode)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
AssertionError: 0 != 1


https://docs.python.org/3.15/whatsnew/3.15.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.15/fedora-rawhide-x86_64/10038379-cmakelang/

For all our attempts to build cmakelang with Python 3.15, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.15/package/cmakelang/

Testing and mass rebuild of packages is happening in copr.
You can follow these instructions to test locally in mock if your package builds with Python 3.15:
https://copr.fedorainfracloud.org/coprs/g/python/python3.15/

Let us know here if you have any questions.

Python 3.15 is planned to be included in Fedora 45.
To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.15.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires),
so if this package is required a lot, it's important for us to get it fixed soon.

We'd appreciate help from the people who know this package best,
but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 Christoph Erhardt 2026-02-01 14:30:44 UTC
This is a tough one.

The package uses Python's undocumented `re.Scanner` class in one place. Starting with Python 3.15, the use of capturing groups in `re.Scanner` is banned: https://github.com/python/cpython/pull/140944

cmakelang uses capturing groups in five places.
In three places, it seems the groups do not have to be capturing so they an easily be made non-capturing.
However, there are two places that use back-references in order to match an equal number of = signs before and after an arbitrary string wrapped in square brackets. I'm not sure how - if at all - these patterns can be transformed into something that does not use capturing.

Upstream seems to be inactive, but I'll keep an eye on their GitHub repo and on other distros to see if a solution comes up.

Comment 2 Christoph Erhardt 2026-02-07 23:41:20 UTC
I have pushed a fix - or rather, an audacious workaround - to the `rawhide` branch. It's nasty and fragile but should do the trick for the time being.


Note You need to log in before you can comment on or make changes to this bug.