Skip to content

gh-140550: Enable limited C API tests on Free Threading in test_cext - #157493

Merged
vstinner merged 3 commits into
python:mainfrom
vstinner:test_cext_abi3t
Sep 15, 2026
Merged

vstinner merged 3 commits into
python:mainfrom
vstinner:test_cext_abi3t

Conversation

@vstinner

@vstinner vstinner commented Sep 14, 2026

Copy link
Copy Markdown
Member

Enable limited C API tests on Free Threading in test_cext and test_cppext: test Py_TARGET_ABI3T macro.

  • Convert test_cppext to PySlot API using PySlot_PTR_STATIC().
  • Define Py_MOD_GIL_NOT_USED in test_cext and test_cppext.
  • Disable C++ test_virtual_object() if Py_TARGET_ABI3T is defined.
  • Remove ";" from PyABIInfo_VAR macro definition, since "PyABIInfo_VAR(abi_info);" added two ";;" which is illegal in C++03.

…_cext

Enable limited C API tests on Free Threading in test_cext and
test_cppext: test Py_TARGET_ABI3T macro.

* Convert test_cppext to PySlot API using PySlot_PTR_STATIC().
* Define Py_MOD_GIL_NOT_USED in test_cext and test_cppext.
* Disable C++ test_virtual_object() if Py_TARGET_ABI3T is defined.
* Remove ";" from PyABIInfo_VAR macro definition, since
  "PyABIInfo_VAR(abi_info);" added two ";;" which is illegal in
  C++03.
@vstinner

Copy link
Copy Markdown
Member Author

cc @encukou

@vstinner vstinner added the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Sep 14, 2026
@vstinner

Copy link
Copy Markdown
Member Author

!buildbot

@vstinner vstinner added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Sep 14, 2026
@bedevere-bot

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @vstinner for commit 9bed8d3 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F157493%2Fmerge

If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Sep 14, 2026
@vstinner

Copy link
Copy Markdown
Member Author

test_limited_cpp03ext() of test_cppext failed on ARM64 macOS:

  /usr/bin/clang++ -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fno-strict-overflow -Wsign-compare -g -Og -Wall -I/Users/buildbot/buildarea/pull_request.pablogsal-macos-m1.macos-with-brew/build/build/test_python_61414æ/tempcwd/env/include -I/Users/buildbot/buildarea/pull_request.pablogsal-macos-m1.macos-with-brew/build/Include -I/Users/buildbot/buildarea/pull_request.pablogsal-macos-m1.macos-with-brew/build -c extension.cpp -o build/temp.macosx-26.6-arm64-cpython-316-pydebug/extension.o -Werror -DMODULE_NAME=_test_limited_cpp03ext -std=c++03 -pedantic-errors -Wno-long-long -DPy_LIMITED_API=0x31000a0
  extension.cpp:332:36: error: cast between pointer-to-function and pointer-to-object is an extension [-Werror,-Wpedantic]
    332 |     PySlot_PTR_STATIC(Py_mod_exec, (void*)_testcppext_exec),
        |                                    ^~~~~~~~~~~~~~~~~~~~~~~
  /Users/buildbot/buildarea/pull_request.pablogsal-macos-m1.macos-with-brew/build/Include/slots.h:54:59: note: expanded from macro 'PySlot_PTR_STATIC'
     54 |     {(NAME), PySlot_INTPTR | PySlot_STATIC, {0}, {(void*)(VALUE)}}
        |                                                           ^~~~~

test.pythoninfo logs CC.version: Apple clang version 21.0.0 (clang-2100.1.1.101), so I guess that it's clang++ 21.0.0. test.pythoninfo should also lox CXX.version.

I supposed that we should disable -Wpedantic on PySlot defintions, as do already on the PyModuleDef_Slot definitions.

@encukou

encukou commented Sep 14, 2026

Copy link
Copy Markdown
Member

I supposed that we should disable -Wpedantic on PySlot defintions

Only on PySlot_PTR & PySlot_PTR_STATIC (that is, the shims added for compatibility with C++11, but trade off pedantic type safety -- exactly as the test found out).

@vstinner

Copy link
Copy Markdown
Member Author

x86-64 MacOS Intel NoGIL PR failed the same way: test_limited_cpp03ext() of test_cppext failed with:

  /usr/bin/clang++ -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fno-strict-overflow -Wsign-compare -g -Og -Wall -I/Users/buildbot/buildarea/pull_request.itamaro-macos-intel-aws.nogil/build/build/test_python_58460æ/tempcwd/env/include -I/Users/buildbot/buildarea/pull_request.itamaro-macos-intel-aws.nogil/build/Include -I/Users/buildbot/buildarea/pull_request.itamaro-macos-intel-aws.nogil/build -c extension.cpp -o build/temp.macosx-13.7-x86_64-cpython-316t-pydebug/extension.o -Werror -DMODULE_NAME=_test_limited_cpp03ext -std=c++03 -pedantic-errors -Wno-long-long -DPy_LIMITED_API=0x31000a0
  extension.cpp:332:36: error: cast between pointer-to-function and pointer-to-object is an extension [-Werror,-Wpedantic]
      PySlot_PTR_STATIC(Py_mod_exec, (void*)_testcppext_exec),
                                     ^~~~~~~~~~~~~~~~~~~~~~~
  /Users/buildbot/buildarea/pull_request.itamaro-macos-intel-aws.nogil/build/Include/slots.h:54:59: note: expanded from macro 'PySlot_PTR_STATIC'
      {(NAME), PySlot_INTPTR | PySlot_STATIC, {0}, {(void*)(VALUE)}}
                                                            ^~~~~

test_cppext uses clang++. test.pythoninfo says CC.version: Apple clang version 15.0.0 (clang-1500.1.0.2.5).

@vstinner

Copy link
Copy Markdown
Member Author

!buildbot ARM64 macOS PR

@bedevere-bot

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @vstinner for commit 5b05582 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F157493%2Fmerge

The command will test the builders whose names match following regular expression: ARM64 macOS PR

The builders matched are:

  • ARM64 macOS PR

@vstinner

Copy link
Copy Markdown
Member Author

!buildbot x86-64 MacOS Intel NoGIL PR

@bedevere-bot

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @vstinner for commit 5b05582 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F157493%2Fmerge

The command will test the builders whose names match following regular expression: x86-64 MacOS Intel NoGIL PR

The builders matched are:

  • x86-64 MacOS Intel NoGIL PR

@vstinner

Copy link
Copy Markdown
Member Author

I pushed a fix for the warning on "cast between pointer-to-function and pointer-to-object is an extension" in pedantic mode.

@vstinner

Copy link
Copy Markdown
Member Author

!buildbot x86-64 MacOS Intel NoGIL PR

@bedevere-bot

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @vstinner for commit 5b05582 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F157493%2Fmerge

The command will test the builders whose names match following regular expression: x86-64 MacOS Intel NoGIL PR

The builders matched are:

  • x86-64 MacOS Intel NoGIL PR

@vstinner

Copy link
Copy Markdown
Member Author

Good, the test suite passed on "buildbot/ARM64 macOS PR" and "buildbot/x86-64 MacOS Intel NoGIL PR".

@vstinner

Copy link
Copy Markdown
Member Author

I will wait until #157539 is merged, and then merge this change on top of it.

@vstinner
vstinner enabled auto-merge (squash) September 15, 2026 14:46
@vstinner
vstinner merged commit fb123c8 into python:main Sep 15, 2026
54 checks passed
@vstinner
vstinner deleted the test_cext_abi3t branch September 15, 2026 15:17
@miss-islington-app

Copy link
Copy Markdown

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Sep 15, 2026

Copy link
Copy Markdown

GH-157560 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Sep 15, 2026
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.

3 participants