gh-91321: Add _Py_NULL macro (#92253)

Fix C++ compiler warnings: "zero as null pointer constant"
(clang -Wzero-as-null-pointer-constant).

* Add the _Py_NULL macro used by static inline functions to use
  nullptr in C++.
* Replace NULL with nullptr in _testcppext.cpp.
This commit is contained in:
Victor Stinner 2022-05-03 21:38:37 +02:00 committed by GitHub
parent 456cd513e3
commit 551d02b3e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 28 additions and 18 deletions

View file

@ -587,7 +587,7 @@ static inline void Py_DECREF(PyObject *op)
/* Function to use in case the object pointer can be NULL: */
static inline void Py_XINCREF(PyObject *op)
{
if (op != NULL) {
if (op != _Py_NULL) {
Py_INCREF(op);
}
}
@ -597,7 +597,7 @@ static inline void Py_XINCREF(PyObject *op)
static inline void Py_XDECREF(PyObject *op)
{
if (op != NULL) {
if (op != _Py_NULL) {
Py_DECREF(op);
}
}