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

@ -52,7 +52,7 @@ test_api_casts(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args))
static PyMethodDef _testcppext_methods[] = {
{"add", _testcppext_add, METH_VARARGS, _testcppext_add_doc},
{"test_api_casts", test_api_casts, METH_NOARGS, NULL},
{"test_api_casts", test_api_casts, METH_NOARGS, nullptr},
{nullptr, nullptr, 0, nullptr} /* sentinel */
};
@ -68,7 +68,7 @@ _testcppext_exec(PyObject *module)
static PyModuleDef_Slot _testcppext_slots[] = {
{Py_mod_exec, reinterpret_cast<void*>(_testcppext_exec)},
{0, NULL}
{0, nullptr}
};
@ -81,8 +81,8 @@ static struct PyModuleDef _testcppext_module = {
0, // m_size
_testcppext_methods, // m_methods
_testcppext_slots, // m_slots
NULL, // m_traverse
NULL, // m_clear
nullptr, // m_traverse
nullptr, // m_clear
nullptr, // m_free
};