Error with zope buildout at build of Persistence

Hi,
We have Zope 5.5 running with Python 3.9 and we are trying to set it up on another system with Python 3.11. Both are SLES 15 but the first is SP4 and the 2nd is SP5. We get this error:

× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [34 lines of output]
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-cpython-311
creating build/lib.linux-x86_64-cpython-311/Persistence
copying src/Persistence/init.py -> build/lib.linux-x86_64-cpython-311/Persistence
copying src/Persistence/mapping.py -> build/lib.linux-x86_64-cpython-311/Persistence
creating build/lib.linux-x86_64-cpython-311/Persistence/tests
copying src/Persistence/tests/init.py -> build/lib.linux-x86_64-cpython-311/Persistence/tests
copying src/Persistence/tests/test_mapping.py -> build/lib.linux-x86_64-cpython-311/Persistence/tests
copying src/Persistence/tests/test_ec.py -> build/lib.linux-x86_64-cpython-311/Persistence/tests
copying src/Persistence/tests/test_persistent.py -> build/lib.linux-x86_64-cpython-311/Persistence/tests
running egg_info
writing src/Persistence.egg-info/PKG-INFO
writing dependency_links to src/Persistence.egg-info/dependency_links.txt
writing requirements to src/Persistence.egg-info/requires.txt
writing top-level names to src/Persistence.egg-info/top_level.txt
reading manifest file 'src/Persistence.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
adding license file 'LICENSE.txt'
writing manifest file 'src/Persistence.egg-info/SOURCES.txt'
copying src/Persistence/_Persistence.c -> build/lib.linux-x86_64-cpython-311/Persistence
running build_ext
building 'Persistence._Persistence' extension
creating build/temp.linux-x86_64-cpython-311
creating build/temp.linux-x86_64-cpython-311/src
creating build/temp.linux-x86_64-cpython-311/src/Persistence
gcc -pthread -Wsign-compare -DNDEBUG -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g -DOPENSSL_LOAD_CONF -fwrapv -fno-semantic-interposition -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g -IVendor/ -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g -IVendor/ -fPIC -Iinclude -Isrc -I/work/ckt/zope/include -I/usr/include/python3.11 -c src/Persistence/_Persistence.c -o build/temp.linux-x86_64-cpython-311/src/Persistence/_Persistence.o
src/Persistence/_Persistence.c: In function ‘module_init’:
src/Persistence/_Persistence.c:178:19: error: lvalue required as left operand of assignment
Py_TYPE(&Ptype) = ECExtensionClassType;
^
error: command '/usr/bin/gcc' failed with exit code 1
[end of output]

This seems to be an error with gcc but it is the same version in both systems and the same Persistence 3.2.
Any ideas what could be wrong?

I see now that only Persistence 3.3 supports Python 3.11. Will try to upgrade Zope to the latest.

The Zope changelog says support for Python 3.11 was added in version 5.7

Use a more recent Zope version, Zope 5.5 does not support Python 3.11.
You can try that newer Zope version with Python 3.9 first.
Newer Zope versions automatically come with matching versions of the dependencies. In case of Persistence is will use version 4.0.post1.

Thanks David, Michael. It only dawned on me too late that Zope 5.5 would be too old for Python 3.11.

I can't recall if we overlooked a warning, but I suppose buildout should warn about mismatches between versions of Python and Zope?

No, zc.buildout ignores python_requires in setup.py. It predates that setting.
Additionally we usually do not set an upper version bound, so there is no way (even not for pip) to tell that your Python version might be too new.