gh-141563: Don't test datetime.h with the limited C API (#144673)

Fix test_cext and test_cppext.
This commit is contained in:
Victor Stinner 2026-02-10 16:45:24 +01:00 committed by GitHub
parent 3dadc22a27
commit 23d45f0c24
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 0 deletions

View file

@ -54,10 +54,13 @@ _testcext_add(PyObject *Py_UNUSED(module), PyObject *args)
static PyObject *
test_datetime(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args))
{
// datetime.h is excluded from the limited C API
#ifndef Py_LIMITED_API
PyDateTime_IMPORT;
if (PyErr_Occurred()) {
return NULL;
}
#endif
Py_RETURN_NONE;
}

View file

@ -232,10 +232,13 @@ test_virtual_object(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args))
static PyObject *
test_datetime(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args))
{
// datetime.h is excluded from the limited C API
#ifndef Py_LIMITED_API
PyDateTime_IMPORT;
if (PyErr_Occurred()) {
return NULL;
}
#endif
Py_RETURN_NONE;
}