8000 [3.10] bpo-44378: Fix a compiler warning in Py_IS_TYPE() (GH-26644) by miss-islington · Pull Request #26668 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

[3.10] bpo-44378: Fix a compiler warning in Py_IS_TYPE() (GH-26644) #26668

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
bpo-44378: Fix a compiler warning in Py_IS_TYPE() (GH-26644)
Py_IS_TYPE() no longer uses Py_TYPE() to avoid a compiler warning:
no longer cast "const PyObject*" to "PyObject*".
(cherry picked from commit 304dfec)

Co-authored-by: Victor Stinner <vstinner@python.org>
  • Loading branch information
vstinner authored and miss-islington committed Jun 11, 2021
commit 23ae2c6b7f62629937f37cb41997211b99432b29
4 changes: 3 additions & 1 deletion Include/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ static inline Py_ssize_t _Py_REFCNT(const PyObject *ob) {


static inline int _Py_IS_TYPE(const PyObject *ob, const PyTypeObject *type) {
return Py_TYPE(ob) == type;
// bpo-44378: Don't use Py_TYPE() since Py_TYPE() requires a non-const
// object.
return ob->ob_type == type;
}
#define Py_IS_TYPE(ob, type) _Py_IS_TYPE(_PyObject_CAST_CONST(ob), type)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:c:func:`Py_IS_TYPE` no longer uses :c:func:`Py_TYPE` to avoid a compiler
warning: no longer cast ``const PyObject*`` to ``PyObject*``.
Patch by Victor Stinner.
0