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-158810: Fix Py_ARRAY_LENGTH() macro on C++ by vstinner · Pull Request #158812 · python/cpython

Conversation

@vstinner

@vstinner vstinner commented Oct 4, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member
  • Issue: [C API] Py_ARRAY_LENGTH() macro is incompatible with g++ -std=gnu++11 #158810

Sorry, something went wrong.

Uh oh!

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

All reactions
@vstinner
pythongh-158810: Fix Py_ARRAY_LENGTH() macro on C++
9d6063a
@bedevere-app bedevere-app Bot mentioned this pull request Oct 4, 2026
[C API] Py_ARRAY_LENGTH() macro is incompatible with g++ -std=gnu++11 #158810
Closed
@bedevere-app bedevere-app Bot added the awaiting core review label Oct 4, 2026
@vstinner

vstinner commented Oct 4, 2026

Copy link
Copy Markdown
Member Author

I tested manually that the added test fails without the fix with g++ 16.2.1 (on Fedora 44): TestPublicCpp.test_build of test_cext fails in this case. The test pass with the fix.

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner
vstinner merged commit b2bfbce into python:main Oct 5, 2026
56 checks passed

Uh oh!

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

@vstinner
vstinner deleted the array_length branch October 5, 2026 11:30
@bedevere-app bedevere-app Bot removed the awaiting core review label Oct 5, 2026
@vstinner

vstinner commented Oct 5, 2026

Copy link
Copy Markdown
Member Author

I will backport the change to stable branches once the 3.15 branch will be unlocked (next week). I should first backport the test_cext refactoring which merged C and C++ tests in test_cext (remove test_cppext).

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-bot

bedevere-bot commented Oct 5, 2026

Copy link
Copy Markdown

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot ARM64 macOS 3.x (tier-2) has failed when building commit b2bfbce.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/725/builds/14663) and take a look at the build logs.
  4. Check if the failure is related to this commit (b2bfbce) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/#/builders/725/builds/14663

Failed tests:

  • test_cext

Failed subtests:

  • test_build_abi3t - test.test_cext.TestPublicC.test_build_abi3t
  • test_build - test.test_cext.TestPublicC.test_build
  • test_build_limited - test.test_cext.TestPublicC.test_build_limited

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/test_cext/__init__.py", line 127, in test_build_limited
    self.check_build('_test_cext_limited', limited=True)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/test_cext/__init__.py", line 101, in check_build
    run_cmd('Install', cmd)
    ~~~~~~~^^^^^^^^^^^^^^^^
  File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/test_cext/__init__.py", line 81, in run_cmd
    subprocess.run(cmd, check=True, env=env)
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/subprocess.py", line 692, in run
    raise CalledProcessError(retcode, process.args,
                             output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command ['/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/build/test_python_28872æ/tempcwd/env/bin/python.exe', '-X', 'dev', '-m', 'pip', 'install', '--no-build-isolation', '/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/build/test_python_28872æ/tempcwd/pkg', '-v'] returned non-zero exit status 1.


Traceback (most recent call last):
  File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/test_cext/__init__.py", line 134, in test_build_abi3t
    self.check_build('_test_cext_abi3t', abi3t=True)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/test_cext/__init__.py", line 101, in check_build
    run_cmd('Install', cmd)
    ~~~~~~~^^^^^^^^^^^^^^^^
  File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/test_cext/__init__.py", line 81, in run_cmd
    subprocess.run(cmd, check=True, env=env)
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/subprocess.py", line 692, in run
    raise CalledProcessError(retcode, process.args,
                             output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command ['/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/build/test_python_28872æ/tempcwd/env/bin/python.exe', '-X', 'dev', '-m', 'pip', 'install', '--no-build-isolation', '/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/build/test_python_28872æ/tempcwd/pkg', '-v'] returned non-zero exit status 1.


Traceback (most recent call last):
  File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/test_cext/__init__.py", line 114, in test_build
    self.check_build('_test_cext')
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
  File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/test_cext/__init__.py", line 101, in check_build
    run_cmd('Install', cmd)
    ~~~~~~~^^^^^^^^^^^^^^^^
  File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/test_cext/__init__.py", line 81, in run_cmd
    subprocess.run(cmd, check=True, env=env)
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/subprocess.py", line 692, in run
    raise CalledProcessError(retcode, process.args,
                             output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command ['/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/build/test_python_28872æ/tempcwd/env/bin/python.exe', '-X', 'dev', '-m', 'pip', 'install', '--no-build-isolation', '/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/build/test_python_28872æ/tempcwd/pkg', '-v'] returned non-zero exit status 1.


Traceback (most recent call last):
  File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/test_cext/__init__.py", line 134, in test_build_abi3t
    self.check_build('_test_cext_abi3t', abi3t=True)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/test_cext/__init__.py", line 101, in check_build
    run_cmd('Install', cmd)
    ~~~~~~~^^^^^^^^^^^^^^^^
  File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/test_cext/__init__.py", line 81, in run_cmd
    subprocess.run(cmd, check=True, env=env)
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/subprocess.py", line 692, in run
    raise CalledProcessError(retcode, process.args,
                             output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command ['/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/build/test_python_32288æ/tempcwd/env/bin/python.exe', '-X', 'dev', '-m', 'pip', 'install', '--no-build-isolation', '/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/build/test_python_32288æ/tempcwd/pkg', '-v'] returned non-zero exit status 1.


Traceback (most recent call last):
  File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/test_cext/__init__.py", line 114, in test_build
    self.check_build('_test_cext')
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
  File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/test_cext/__init__.py", line 101, in check_build
    run_cmd('Install', cmd)
    ~~~~~~~^^^^^^^^^^^^^^^^
  File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/test_cext/__init__.py", line 81, in run_cmd
    subprocess.run(cmd, check=True, env=env)
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/subprocess.py", line 692, in run
    raise CalledProcessError(retcode, process.args,
                             output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command ['/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/build/test_python_32288æ/tempcwd/env/bin/python.exe', '-X', 'dev', '-m', 'pip', 'install', '--no-build-isolation', '/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/build/test_python_32288æ/tempcwd/pkg', '-v'] returned non-zero exit status 1.


Traceback (most recent call last):
  File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/test_cext/__init__.py", line 127, in test_build_limited
    self.check_build('_test_cext_limited', limited=True)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/test_cext/__init__.py", line 101, in check_build
    run_cmd('Install', cmd)
    ~~~~~~~^^^^^^^^^^^^^^^^
  File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/test_cext/__init__.py", line 81, in run_cmd
    subprocess.run(cmd, check=True, env=env)
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/subprocess.py", line 692, in run
    raise CalledProcessError(retcode, process.args,
                             output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command ['/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/build/test_python_32288æ/tempcwd/env/bin/python.exe', '-X', 'dev', '-m', 'pip', 'install', '--no-build-isolation', '/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/build/test_python_32288æ/tempcwd/pkg', '-v'] returned non-zero exit status 1.
All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner

vstinner commented Oct 5, 2026

Copy link
Copy Markdown
Member Author

Hi! The buildbot ARM64 macOS 3.x (tier-2) has failed

Ah, 3 tests build C extensions failed:

ERROR: test_build (test.test_cext.TestPublicC.test_build)
ERROR: test_build_abi3t (test.test_cext.TestPublicC.test_build_abi3t)
ERROR: test_build_limited (test.test_cext.TestPublicC.test_build_limited)

Example of error: extension used: (...) typeof()

  gcc -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fno-strict-overflow -Wsign-compare -g -Og -Wall -I/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/build/test_python_28872æ/tempcwd/env/include -I/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Include -I/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build -c extension.c -o build/temp.macosx-26.6-arm64-cpython-316-pydebug/extension.o -Werror -D_Py_IS_TESTCEXT -Wcast-qual -pedantic-errors -Werror=declaration-after-statement -DMODULE_NAME=_test_cext
  extension.c:139:12: error: extension used [-Werror,-Wlanguage-extension-token]
    139 |     assert(Py_ARRAY_LENGTH(small_array) == 3);
        |            ^
  /Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Include/pymacro.h:221:59: note: expanded from macro 'Py_ARRAY_LENGTH'
    221 |      + Py_BUILD_ASSERT_EXPR(!__builtin_types_compatible_p(typeof(array), \
        |                                                           ^
  extension.c:139:12: error: extension used [-Werror,-Wlanguage-extension-token]
  /Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Include/pymacro.h:222:59: note: expanded from macro 'Py_ARRAY_LENGTH'
    222 |                                                           typeof(&(array)[0]))))
        |                                                           ^
  extension.c:139:12: error: extension used [-Werror,-Wlanguage-extension-token]
  /Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Include/pymacro.h:221:59: note: expanded from macro 'Py_ARRAY_LENGTH'
    221 |      + Py_BUILD_ASSERT_EXPR(!__builtin_types_compatible_p(typeof(array), \
        |                                                           ^
  extension.c:139:12: error: extension used [-Werror,-Wlanguage-extension-token]
  /Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Include/pymacro.h:222:59: note: expanded from macro 'Py_ARRAY_LENGTH'
    222 |                                                           typeof(&(array)[0]))))
        |                                                           ^
  4 errors generated.
All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner

vstinner commented Oct 5, 2026

Copy link
Copy Markdown
Member Author

I wrote PR #158838 to fix the "extension used" error.

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 13, 2026
@vstinner
[3.15] gh-158810: Fix Py_ARRAY_LENGTH() macro on C++ (#159315)
152185f
* gh-158810: Fix Py_ARRAY_LENGTH() macro on C++ (#158812)

(cherry picked from commit b2bfbce)

* gh-158810: Use _Py_TYPEOF in Py_ARRAY_LENGTH() (#158838)

Fix the compiler warning "extension used" when building test_cext
with clang.

* test_cext no longer overrides the CC environment variable if it's
  already defined.
* test_cext now also logs __STRICT_ANSI__ macro.

(cherry picked from commit 85c03d4)

* Add Py_SETREF/XSETREF tests to test_cext
vstinner added a commit that referenced this pull request Oct 13, 2026
@vstinner
[3.14] gh-158810: Fix Py_ARRAY_LENGTH() macro on C++ (#159317)
931322b
* [3.15] gh-158810: Fix Py_ARRAY_LENGTH() macro on C++ (#159315)

* gh-158810: Fix Py_ARRAY_LENGTH() macro on C++ (#158812)

(cherry picked from commit b2bfbce)

* gh-158810: Use _Py_TYPEOF in Py_ARRAY_LENGTH() (#158838)

Fix the compiler warning "extension used" when building test_cext
with clang.

* test_cext no longer overrides the CC environment variable if it's
  already defined.
* test_cext now also logs __STRICT_ANSI__ macro.

(cherry picked from commit 85c03d4)

* Add Py_SETREF/XSETREF tests to test_cext

(cherry picked from commit 152185f)

* Backport Py_CLEAR/Py_SETREF/Py_XSETREF from main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

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

Assignees

No one assigned

Labels

None yet

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.