https://github.com/python/cpython/commit/23d45f0c24ab4ed6fa9bf21ddced78650aa7ae30
commit: 23d45f0c24ab4ed6fa9bf21ddced78650aa7ae30
branch: main
author: Victor Stinner <[email protected]>
committer: vstinner <[email protected]>
date: 2026-02-10T15:45:24Z
summary:
gh-141563: Don't test datetime.h with the limited C API (#144673)
Fix test_cext and test_cppext.
files:
M Lib/test/test_cext/extension.c
M Lib/test/test_cppext/extension.cpp
diff --git a/Lib/test/test_cext/extension.c b/Lib/test/test_cext/extension.c
index 20c2b6e89d8e17..28531b47383b85 100644
--- a/Lib/test/test_cext/extension.c
+++ b/Lib/test/test_cext/extension.c
@@ -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;
}
diff --git a/Lib/test/test_cppext/extension.cpp
b/Lib/test/test_cppext/extension.cpp
index 51271250366429..7d360f88fdd1f1 100644
--- a/Lib/test/test_cppext/extension.cpp
+++ b/Lib/test/test_cppext/extension.cpp
@@ -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;
}
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]