Skip to content

Commit 23d45f0

Browse files
authored
gh-141563: Don't test datetime.h with the limited C API (#144673)
Fix test_cext and test_cppext.
1 parent 3dadc22 commit 23d45f0

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

Lib/test/test_cext/extension.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,13 @@ _testcext_add(PyObject *Py_UNUSED(module), PyObject *args)
5454
static PyObject *
5555
test_datetime(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args))
5656
{
57+
// datetime.h is excluded from the limited C API
58+
#ifndef Py_LIMITED_API
5759
PyDateTime_IMPORT;
5860
if (PyErr_Occurred()) {
5961
return NULL;
6062
}
63+
#endif
6164

6265
Py_RETURN_NONE;
6366
}

Lib/test/test_cppext/extension.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,13 @@ test_virtual_object(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args))
232232
static PyObject *
233233
test_datetime(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args))
234234
{
235+
// datetime.h is excluded from the limited C API
236+
#ifndef Py_LIMITED_API
235237
PyDateTime_IMPORT;
236238
if (PyErr_Occurred()) {
237239
return NULL;
238240
}
241+
#endif
239242

240243
Py_RETURN_NONE;
241244
}

0 commit comments

Comments
 (0)