]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-93442: Make C++ version of _Py_CAST work with 0/NULL. (GH-93500) (gh-93507)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 5 Jun 2022 05:15:59 +0000 (22:15 -0700)
committerGitHub <noreply@github.com>
Sun, 5 Jun 2022 05:15:59 +0000 (14:15 +0900)
commitd97e2c52d3c7d0f3800cbed3371005295be78921
treeb34ff9dc033f243698e143f068fb1b9d0d512ecc
parent4443c285a61f2dab4de6c383abad3580bf2aa06d
gh-93442: Make C++ version of _Py_CAST work with 0/NULL. (GH-93500) (gh-93507)

Add C++ overloads for _Py_CAST_impl() to handle 0/NULL.  This will allow
C++ extensions that pass 0 or NULL to macros using _Py_CAST() to
continue to compile.  Without this, you get an error like:

    invalid ‘static_cast’ from type ‘int’ to type ‘_object*’

The modern way to use a NULL value in C++ is to use nullptr.  However,
we want to not break extensions that do things the old way.

Co-authored-by: serge-sans-paille
(cherry picked from commit 8bcc3fa3453e28511d04eaa0aa7d8e1a3495d518)

Co-authored-by: Neil Schemenauer <nas-github@arctrix.com>
Co-authored-by: Neil Schemenauer <nas-github@arctrix.com>
Include/pyport.h
Lib/test/_testcppext.cpp
Misc/NEWS.d/next/C API/2022-06-04-13-15-41.gh-issue-93442.4M4NDb.rst [new file with mode: 0644]