close
Skip to content

[BUG] cythonize does not work on 3.1.0 + gcc 4.8 #6861

Description

@oraluben

Describe the bug

As title.

Example took from https://github.com/pypa/auditwheel/tree/main/tests/integration/sample_extension

git clone https://github.com/pypa/auditwheel.git
cd auditwheel
docker run -v `pwd`:/auditwheel_src -ti quay.io/pypa/manylinux1_x86_64
/opt/_internal/cpython-3.9.19/bin/python -mvenv /venv
source /venv/bin/activate
pip install cython==3.1.0
cd /auditwheel_src/tests/integration/sample_extension/
# This works
cython src/sample_extension.pyx
# This fail
python setup.py develop

Error:

running develop
running egg_info
creating sample_extension.egg-info
writing sample_extension.egg-info/PKG-INFO
writing dependency_links to sample_extension.egg-info/dependency_links.txt
writing top-level names to sample_extension.egg-info/top_level.txt
writing manifest file 'sample_extension.egg-info/SOURCES.txt'
reading manifest file 'sample_extension.egg-info/SOURCES.txt'
writing manifest file 'sample_extension.egg-info/SOURCES.txt'
running build_ext
building 'sample_extension' extension
creating build
creating build/temp.linux-x86_64-3.9
creating build/temp.linux-x86_64-3.9/src
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/venv/include -I/opt/_internal/cpython-3.9.19/include/python3.9 -c src/sample_extension.c -o build/temp.linux-x86_64-3.9/src/sample_extension.o
src/sample_extension.c: In function ‘__pyx_pw_16sample_extension_1test_func’:
src/sample_extension.c:2330:7: error: ‘for’ loop initial declarations are only allowed in C99 mode
       for (Py_ssize_t i = __pyx_nargs; i < 1; i++) {
       ^
src/sample_extension.c:2330:7: note: use option -std=c99 or -std=gnu99 to compile your code
src/sample_extension.c:2347:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
   for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
   ^
src/sample_extension.c:2357:19: error: redefinition of ‘__pyx_temp’
   for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
                   ^
src/sample_extension.c:2347:19: note: previous definition of ‘__pyx_temp’ was here
   for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
                   ^
src/sample_extension.c:2357:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
   for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
   ^
src/sample_extension.c: In function ‘__Pyx_ParseKeywordsTuple’:
src/sample_extension.c:3972:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
     for (Py_ssize_t pos = 0; pos < num_kwargs; pos++) {
     ^
src/sample_extension.c: In function ‘__Pyx_PyCode_New’:
src/sample_extension.c:6876:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
     for (Py_ssize_t i=0; i < var_count; i++) {
     ^
error: command '/opt/rh/devtoolset-2/root/usr/bin/gcc' failed with exit code 1

Code to reproduce the behaviour:

No response

Expected behaviour

No response

OS

Linux

Python version

3.9.19

Cython version

3.1.0 (3.0.11 works)

Additional context

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions