gh-141563: Add missing cast to _PyDateTime_IMPORT() by vstinner · Pull Request #144667 · python/cpython · GitHub
Skip to content
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
2 changes: 1 addition & 1 deletion Include/datetime.h
20 changes: 20 additions & 0 deletions Lib/test/test_cext/extension.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#endif

#include "Python.h"
#include "datetime.h"

#ifdef TEST_INTERNAL_C_API
// gh-135906: Check for compiler warnings in the internal C API.
Expand Down Expand Up @@ -50,8 +51,21 @@ _testcext_add(PyObject *Py_UNUSED(module), PyObject *args)
}


static PyObject *
test_datetime(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args))
{
PyDateTime_IMPORT;
if (PyErr_Occurred()) {
return NULL;
}

Py_RETURN_NONE;
}


static PyMethodDef _testcext_methods[] = {
{"add", _testcext_add, METH_VARARGS, _testcext_add_doc},
{"test_datetime", test_datetime, METH_NOARGS, NULL},
{NULL, NULL, 0, NULL} // sentinel
};

Expand All @@ -65,12 +79,18 @@ _testcext_exec(
#endif
)
{
PyObject *result;

#ifdef __STDC_VERSION__
if (PyModule_AddIntMacro(module, __STDC_VERSION__) < 0) {
return -1;
}
#endif

result = PyObject_CallMethod(module, "test_datetime", "");
if (!result) return -1;
Py_DECREF(result);

// test Py_BUILD_ASSERT() and Py_BUILD_ASSERT_EXPR()
Py_BUILD_ASSERT(sizeof(int) == sizeof(unsigned int));
assert(Py_BUILD_ASSERT_EXPR(sizeof(int) == sizeof(unsigned int)) == 0);
Expand Down
17 changes: 17 additions & 0 deletions Lib/test/test_cppext/extension.cpp
Loading