#include <limits.h> // INT_MAX
#include <math.h> // HUGE_VAL
#include <stdarg.h> // va_list
+#include <string.h> // memcpy()
#include <wchar.h> // wchar_t
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h> // ssize_t
#endif
-// <errno.h>, <stdio.h>, <stdlib.h> and <string.h> headers are no longer used
+// <errno.h>, <stdio.h> and <stdlib.h> headers are no longer used
// by Python, but kept for the backward compatibility of existing third party C
// extensions. They are not included by limited C API version 3.11 and newer.
//
# include <errno.h> // errno
# include <stdio.h> // FILE*
# include <stdlib.h> // getenv()
-# include <string.h> // memcpy()
#endif
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030d0000
# include <ctype.h> // tolower()
//
// Example: _Py_TYPEOF(x) x_copy = (x);
//
-// The macro is only defined if GCC or clang compiler is used.
-#if defined(__GNUC__) || defined(__clang__)
+// On C23, use typeof(). Otherwise, the macro is only defined
+// if GCC or clang compiler is used.
+#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
+# define _Py_TYPEOF(expr) typeof(expr)
+#elif defined(__GNUC__) || defined(__clang__)
# define _Py_TYPEOF(expr) __typeof__(expr)
#endif
static int
_testcext_exec(PyObject *module)
{
- PyObject *result;
+ PyObject *result, *obj;
#ifdef __STDC_VERSION__
if (PyModule_AddIntMacro(module, __STDC_VERSION__) < 0) {
Py_BUILD_ASSERT(sizeof(int) == sizeof(unsigned int));
assert(Py_BUILD_ASSERT_EXPR(sizeof(int) == sizeof(unsigned int)) == 0);
+ // Test Py_CLEAR()
+ obj = NULL;
+ Py_CLEAR(obj);
+
return 0;
}