]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-141563: Don't test datetime.h with the limited C API (#144673)
authorVictor Stinner <vstinner@python.org>
Tue, 10 Feb 2026 15:45:24 +0000 (16:45 +0100)
committerGitHub <noreply@github.com>
Tue, 10 Feb 2026 15:45:24 +0000 (15:45 +0000)
Fix test_cext and test_cppext.

Lib/test/test_cext/extension.c
Lib/test/test_cppext/extension.cpp

index 20c2b6e89d8e17e5774725290391df3675aa6fe5..28531b47383b85543f1e1831856af0aecda2e131 100644 (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;
 }
index 51271250366429b2d67db6981b31a233eaa5f7b5..7d360f88fdd1f11bd41366bfb985f5c7749cd3b8 100644 (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;
 }