Skip to content

Python 3.12 introduces redundant decls warning #106560

Closed

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

Activity

  1. added
    type-bugAn unexpected behavior, bug, or error
    on Jul 9, 2023
  2. added 10 commits that reference this issue on Dec 2, 2023
  3. added a commit that references this issue on Feb 4, 2024
  4. added 2 commits that reference this issue on Feb 11, 2024
  5. hugovk commented on Mar 15, 2024

    @hugovk
    Member

    Closing as the PRs have been merged and backported. Please let us know if there's still more to do. Thanks for the report!

  6. added 2 commits that reference this issue on Sep 2, 2024
  7. added a commit that references this issue on Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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