Author vstinner
Recipients vstinner
Date 2021-06-10.13:19:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1623331194.1.0.529436211827.issue44378@roundup.psfhosted.org>
In-reply-to
Content
The following change introduced a compiler warning:

commit c5cb077ab3c88394b7ac8ed4e746bd31b53e39f1
Author: Victor Stinner <vstinner@python.org>
Date:   Tue Sep 22 12:42:28 2020 +0200

    Py_IS_TYPE() macro uses Py_TYPE() (GH-22341)

Steps to Reproduce:

1. dnf install -y python3-devel pkgconf-pkg-config gcc
2. printf '#include <Python.h>' > test.c
3. gcc -Wcast-qual -Werror -c test.c `pkg-config --cflags --libs python-3.10`

Actual results:
sh-5.1# gcc -Wcast-qual -Werror -c test.c `pkg-config --cflags --libs python-3.10`
In file included from /usr/include/python3.10/Python.h:78,
                 from test.c:1:
/usr/include/python3.10/object.h: In function ‘_Py_IS_TYPE’:
/usr/include/python3.10/object.h:112:29: error: cast discards ‘const’ qualifier from pointer target type [-Werror=cast-qual]
  112 | #define _PyObject_CAST(op) ((PyObject*)(op))
      |                             ^
/usr/include/python3.10/object.h:137:34: note: in expansion of macro ‘_PyObject_CAST’
  137 | #define Py_TYPE(ob)             (_PyObject_CAST(ob)->ob_type)
      |                                  ^~~~~~~~~~~~~~
/usr/include/python3.10/object.h:144:12: note: in expansion of macro ‘Py_TYPE’
  144 |     return Py_TYPE(ob) == type;
      |            ^~~~~~~
cc1: all warnings being treated as errors


Attached PR fix the compiler warning.


Issue reported on Fedora: https://bugzilla.redhat.com/show_bug.cgi?id=1969663
History
Date User Action Args
2021-06-10 13:19:54vstinnersetrecipients: + vstinner
2021-06-10 13:19:54vstinnersetmessageid: <1623331194.1.0.529436211827.issue44378@roundup.psfhosted.org>
2021-06-10 13:19:54vstinnerlinkissue44378 messages
2021-06-10 13:19:53vstinnercreate