Skip to content

Python 3.12 introduces redundant decls warning #106560

@t-8ch

Description

@t-8ch

Bug report

Python 3.12 introduce a -Wredundant-decls warning.

// test.c
#include <Python.h>

int main(void) {}
$ gcc test.c -o test $(pkg-config --cflags python-3.12) -Wredundant-decls
In file included from /usr/include/python3.12/Python.h:52,
                 from test.c:1:
/usr/include/python3.12/longobject.h:10:26: warning: redundant redeclaration of ‘PyLong_Type’ [-Wredundant-decls]
   10 | PyAPI_DATA(PyTypeObject) PyLong_Type;
      |                          ^~~~~~~~~~~
In file included from /usr/include/python3.12/Python.h:44:
/usr/include/python3.12/object.h:210:26: note: previous declaration of ‘PyLong_Type’ with type ‘PyTypeObject’ {aka ‘struct _typeobject’}
  210 | PyAPI_DATA(PyTypeObject) PyLong_Type;
      |                          ^~~~~~~~~~~
In file included from /usr/include/python3.12/Python.h:54:
/usr/include/python3.12/boolobject.h:10:26: warning: redundant redeclaration of ‘PyBool_Type’ [-Wredundant-decls]
   10 | PyAPI_DATA(PyTypeObject) PyBool_Type;
      |                          ^~~~~~~~~~~
/usr/include/python3.12/object.h:211:26: note: previous declaration of ‘PyBool_Type’ with type ‘PyTypeObject’ {aka ‘struct _typeobject’}
  211 | PyAPI_DATA(PyTypeObject) PyBool_Type;
      |        
  • This was introduced in 7559f5f
  • This currently breaks the build/tests of util-linux/pylibmount (with -Werror)

Your environment

  • CPython versions tested on: 3.12.0b3 (should be the same on master)
  • Operating system and architecture: ArchLinux, x86_64

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)topic-C-APItype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      close