GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-157649: Merge test_cppext into test_cext by vstinner · Pull Request #158176 · python/cpython

Conversation

@vstinner

@vstinner vstinner commented Sep 25, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member
  • test_cext now uses a single virtual environment for all tests. It makes the test way faster since creating a virtual environment is quite slow.
  • Add Py_TARGET_ABI3T test on C++.
  • Move macro tests from module exec function to test_macros().
  • Call Py_BEGIN_CRITICAL_SECTION() on a fresh dictionary object, rather than on the module.
  • Rename some environment variables to always use "CPYTHON_TEST_" prefix.
  • Replace support.MS_WINDOWS with MSVC to be more explicit.
  • Move macro tests to test_macros().
  • Issue: Py_CLEAR/Py_SETREF() regression on the main branch with C++: SEGV with simple numpy program #157649

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

chris-eibl reacted with rocket emoji
All reactions
  • 🚀 1 reaction
@vstinner
pythongh-157649: Merge test_cppext into test_cext
18d8ef5
* test_cext now uses a single virtual environment for all tests.
  It makes the test way faster since creating a virtual environment
  is quite slow.
* Add Py_TARGET_ABI3T test on C++.
* Move macro tests from module exec function to test_macros().
* Call Py_BEGIN_CRITICAL_SECTION() on a fresh dictionary object,
  rather than on the module.
* Rename some environment variables to always use "CPYTHON_TEST_"
  prefix.
* Replace support.MS_WINDOWS with MSVC to be more explicit.
* Move macro tests to test_macros().
@vstinner vstinner added the skip news label Sep 25, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Sep 25, 2026
Py_CLEAR/Py_SETREF() regression on the main branch with C++: SEGV with simple numpy program #157649
Closed
@bedevere-app bedevere-app Bot added the awaiting core review label Sep 25, 2026
@vstinner vstinner added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Sep 25, 2026
@bedevere-bot

bedevere-bot commented Sep 25, 2026

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @vstinner for commit 18d8ef5 🤖

Results will be shown at:

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

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Sep 25, 2026
vstinner added 2 commits September 25, 2026 18:26
@vstinner
Remove test_cppext from Makefile TESTSUBDIRS
52dc9ec
@vstinner
Skip test_cext on WASI (need subprocess)
8ee942f
@vstinner
vstinner requested review from AA-Turner, emmatyping, erlend-aasland and itamaro as code owners September 25, 2026 16:29
@vstinner vstinner added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Sep 25, 2026
@bedevere-bot

bedevere-bot commented Sep 25, 2026

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @vstinner for commit 8ee942f 🤖

Results will be shown at:

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

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

vstinner commented Sep 25, 2026

Copy link
Copy Markdown
Member Author

test_cext and test_cppext had a lot of duplicated code with only minor differences. Merging the two tests makes sure that most code is shared between C and C++ tests to keep code consistent.

For example, this PR adds PyUnicode tests in C and adds Py_TARGET_ABI3T tests in C++.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vstinner added 2 commits September 25, 2026 22:40
@vstinner
test.pythoninfo logs C++ compiler version
dd81873
@vstinner
On macOS, use C++11 by default
ee31df3
@vstinner

vstinner commented Sep 25, 2026

Copy link
Copy Markdown
Member Author

test_cext fails on macOS:

ERROR: test_build (test.test_cext.TestPublicCpp.test_build)
ERROR: test_build_intel_asm (test.test_cext.TestPublicCpp.test_build_intel_asm)

Example:

Building wheels for collected packages: internal__test_cppext
  Building wheel for internal__test_cppext (pyproject.toml): started
  Running command Building wheel for internal__test_cppext (pyproject.toml)
  Language: C++
  Source: extension.cpp
  CC env var: 'gcc'
  CXX env var: <missing>
  CFLAGS env var: <missing>
  CPPFLAGS env var: <missing>
  CXXFLAGS env var: <missing>
  extra_compile_args: ['-Werror', '-DMODULE_NAME=_test_cppext', '-pedantic-errors', '-Wno-long-long']
  running bdist_wheel
  running build
  running build_ext
  building '_test_cppext' extension
  creating build/temp.macosx-13.7-x86_64-cpython-316t-pydebug
  /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_98426æ/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_cppext -pedantic-errors -Wno-long-long
  In file included from extension.cpp:3:
  In file included from ./extension.c:16:
  In file included from /Users/buildbot/buildarea/pull_request.itamaro-macos-intel-aws.nogil/build/Include/Python.h:72:
  In file included from /Users/buildbot/buildarea/pull_request.itamaro-macos-intel-aws.nogil/build/Include/pymem.h:103:
  /Users/buildbot/buildarea/pull_request.itamaro-macos-intel-aws.nogil/build/Include/cpython/pymem.h:28:39: error: commas at the end of enumerator lists are a C++11 extension [-Werror,-Wc++11-extensions]
      PYMEM_ALLOCATOR_MIMALLOC_DEBUG = 8,
                                        ^
  In file included from extension.cpp:3:
  In file included from ./extension.c:16:
  In file included from /Users/buildbot/buildarea/pull_request.itamaro-macos-intel-aws.nogil/build/Include/Python.h:79:
  In file included from /Users/buildbot/buildarea/pull_request.itamaro-macos-intel-aws.nogil/build/Include/object.h:742:
  /Users/buildbot/buildarea/pull_request.itamaro-macos-intel-aws.nogil/build/Include/cpython/object.h:476:36: error: commas at the end of enumerator lists are a C++11 extension [-Werror,-Wc++11-extensions]
      PyRefTracer_TRACKER_REMOVED = 2,
                                     ^
  In file included from extension.cpp:3:
  In file included from ./extension.c:16:
  In file included from /Users/buildbot/buildarea/pull_request.itamaro-macos-intel-aws.nogil/build/Include/Python.h:99:
  In file included from /Users/buildbot/buildarea/pull_request.itamaro-macos-intel-aws.nogil/build/Include/dictobject.h:113:
  /Users/buildbot/buildarea/pull_request.itamaro-macos-intel-aws.nogil/build/Include/cpython/dictobject.h:90:27: error: commas at the end of enumerator lists are a C++11 extension [-Werror,-Wc++11-extensions]
      PY_FOREACH_DICT_EVENT(PY_DEF_EVENT)
                            ^
  In file included from extension.cpp:3:
  In file included from ./extension.c:16:
  In file included from /Users/buildbot/buildarea/pull_request.itamaro-macos-intel-aws.nogil/build/Include/Python.h:106:
  /Users/buildbot/buildarea/pull_request.itamaro-macos-intel-aws.nogil/build/Include/cpython/funcobject.h:142:27: error: commas at the end of enumerator lists are a C++11 extension [-Werror,-Wc++11-extensions]
      PY_FOREACH_FUNC_EVENT(PY_DEF_EVENT)
                            ^
  In file included from extension.cpp:3:
  In file included from ./extension.c:16:
  In file included from /Users/buildbot/buildarea/pull_request.itamaro-macos-intel-aws.nogil/build/Include/Python.h:110:
  /Users/buildbot/buildarea/pull_request.itamaro-macos-intel-aws.nogil/build/Include/cpython/code.h:236:27: error: commas at the end of enumerator lists are a C++11 extension [-Werror,-Wc++11-extensions]
      PY_FOREACH_CODE_EVENT(PY_DEF_EVENT)
                            ^
  In file included from extension.cpp:3:
  In file included from ./extension.c:16:
  In file included from /Users/buildbot/buildarea/pull_request.itamaro-macos-intel-aws.nogil/build/Include/Python.h:129:
  /Users/buildbot/buildarea/pull_request.itamaro-macos-intel-aws.nogil/build/Include/cpython/context.h:36:28: error: commas at the end of enumerator lists are a C++11 extension [-Werror,-Wc++11-extensions]
      Py_CONTEXT_SWITCHED = 1,
                             ^
  6 errors generated.
  error: command '/usr/bin/clang++' failed with exit code 1

It seems like clang++ uses a C++ version older than C++11 by default. It's likely the old Apple clang++ which uses gnu++98 by default. I changed the two affected TestPublicCpp tests to use C++11 by default on macOS.

It's unclear to me why the same passed on macOS before this change. But I don't have access to macOS, so I cannot investigate. Well, my change should fix macOS support.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Sep 25, 2026

Copy link
Copy Markdown
Member Author

!buildbot x86-64 MacOS

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot

bedevere-bot commented Sep 25, 2026

Copy link
Copy Markdown

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

Results will be shown at:

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

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

The builders matched are:

  • x86-64 macOS PR
  • x86-64 MacOS Intel NoGIL PR
  • x86-64 MacOS Intel ASAN NoGIL PR
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Sep 25, 2026

Copy link
Copy Markdown
Member Author

!buildbot AMD64 Fedora Stable

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot

bedevere-bot commented Sep 25, 2026

Copy link
Copy Markdown

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

Results will be shown at:

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

The command will test the builders whose names match following regular expression: AMD64 Fedora Stable

The builders matched are:

  • AMD64 Fedora Stable LTO + PGO PR
  • AMD64 Fedora Stable LTO PR
  • AMD64 Fedora Stable PR
  • AMD64 Fedora Stable Clang PR
  • AMD64 Fedora Stable Clang Installed PR
  • AMD64 Fedora Stable Refleaks PR
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner
test.pythoninfo: log CC/CXX command
2a88c6e
@vstinner
vstinner enabled auto-merge (squash) September 25, 2026 22:00
@vstinner
vstinner merged commit b71989d into python:main Sep 25, 2026
52 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@vstinner
vstinner deleted the merge_test_cext branch September 25, 2026 22:31
@bedevere-app bedevere-app Bot removed the awaiting core review label Sep 25, 2026
@vstinner vstinner mentioned this pull request Sep 28, 2026
gh-157649: Fix Py_CLEAR()/Py_SETREF() on C++ #158070
Merged
@bedevere-app

bedevere-app Bot commented Oct 12, 2026

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vstinner added a commit that referenced this pull request Oct 12, 2026
@vstinner
[3.15] gh-157649: Merge test_cppext into test_cext (#158176) (#159264)
364db5d
* test_cext now uses a single virtual environment for all tests.
  It makes the test way faster since creating a virtual environment
  is quite slow.
* Add Py_TARGET_ABI3T test on C++.
* Move macro tests from module exec function to test_macros().
* Call Py_BEGIN_CRITICAL_SECTION() on a fresh dictionary object,
  rather than on the module.
* Rename some environment variables to always use "CPYTHON_TEST_"
  prefix.
* Replace support.MS_WINDOWS with MSVC to be more explicit.
* Move macro tests to test_macros().
* On macOS, use C++11 by default.

(cherry picked from commit b71989d)
vstinner added a commit that referenced this pull request Oct 13, 2026
@vstinner
[3.14] gh-157649: Merge test_cppext into test_cext (#158176) (#159264) (
1d0f58b
#159276)

* [3.15] gh-157649: Merge test_cppext into test_cext (#158176) (#159264)

* test_cext now uses a single virtual environment for all tests.
  It makes the test way faster since creating a virtual environment
  is quite slow.
* Add Py_TARGET_ABI3T test on C++.
* Move macro tests from module exec function to test_macros().
* Call Py_BEGIN_CRITICAL_SECTION() on a fresh dictionary object,
  rather than on the module.
* Rename some environment variables to always use "CPYTHON_TEST_"
  prefix.
* Replace support.MS_WINDOWS with MSVC to be more explicit.
* Move macro tests to test_macros().
* On macOS, use C++11 by default.

(cherry picked from commit b71989d)
(cherry picked from commit 364db5d)

* Fix warning about unused dict
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@erlend-aasland erlend-aasland Awaiting requested review from erlend-aasland erlend-aasland is a code owner
@AA-Turner AA-Turner Awaiting requested review from AA-Turner AA-Turner is a code owner
@emmatyping emmatyping Awaiting requested review from emmatyping emmatyping is a code owner
@itamaro itamaro Awaiting requested review from itamaro itamaro is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@vstinner @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.