File tree Expand file tree Collapse file tree 5 files changed +16
-6
lines changed
Expand file tree Collapse file tree 5 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -123,6 +123,7 @@ System includes
123123 * ``<limits.h> ``
124124 * ``<math.h> ``
125125 * ``<stdarg.h> ``
126+ * ``<string.h> ``
126127 * ``<wchar.h> ``
127128 * ``<sys/types.h> `` (if present)
128129
@@ -138,7 +139,6 @@ System includes
138139 * ``<errno.h> ``
139140 * ``<stdio.h> ``
140141 * ``<stdlib.h> ``
141- * ``<string.h> ``
142142
143143.. note ::
144144
Original file line number Diff line number Diff line change 2222#include <limits.h> // INT_MAX
2323#include <math.h> // HUGE_VAL
2424#include <stdarg.h> // va_list
25+ #include <string.h> // memcpy()
2526#include <wchar.h> // wchar_t
2627#ifdef HAVE_SYS_TYPES_H
2728# include <sys/types.h> // ssize_t
2829#endif
2930
30- // <errno.h>, <stdio.h>, <stdlib.h> and <string .h> headers are no longer used
31+ // <errno.h>, <stdio.h> and <stdlib .h> headers are no longer used
3132// by Python, but kept for the backward compatibility of existing third party C
3233// extensions. They are not included by limited C API version 3.11 and newer.
3334//
3738# include <errno.h> // errno
3839# include <stdio.h> // FILE*
3940# include <stdlib.h> // getenv()
40- # include <string.h> // memcpy()
4141#endif
4242#if !defined(Py_LIMITED_API ) || Py_LIMITED_API + 0 < 0x030d0000
4343# include <ctype.h> // tolower()
Original file line number Diff line number Diff line change @@ -567,8 +567,11 @@ extern "C" {
567567//
568568// Example: _Py_TYPEOF(x) x_copy = (x);
569569//
570- // The macro is only defined if GCC or clang compiler is used.
571- #if defined(__GNUC__) || defined(__clang__)
570+ // On C23, use typeof(). Otherwise, the macro is only defined
571+ // if GCC or clang compiler is used.
572+ #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
573+ # define _Py_TYPEOF (expr ) typeof (expr)
574+ #elif defined(__GNUC__) || defined(__clang__)
572575# define _Py_TYPEOF (expr ) __typeof__(expr)
573576#endif
574577
Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ static PyMethodDef _testcext_methods[] = {
7676static int
7777_testcext_exec (PyObject * module )
7878{
79- PyObject * result ;
79+ PyObject * result , * obj ;
8080
8181#ifdef __STDC_VERSION__
8282 if (PyModule_AddIntMacro (module , __STDC_VERSION__ ) < 0 ) {
@@ -92,6 +92,10 @@ _testcext_exec(PyObject *module)
9292 Py_BUILD_ASSERT (sizeof (int ) == sizeof (unsigned int ));
9393 assert (Py_BUILD_ASSERT_EXPR (sizeof (int ) == sizeof (unsigned int )) == 0 );
9494
95+ // Test Py_CLEAR()
96+ obj = NULL ;
97+ Py_CLEAR (obj );
98+
9599 return 0 ;
96100}
97101
Original file line number Diff line number Diff line change 1+ ``Python.h `` now also includes ``<string.h> `` in the limited C API version 3.11
2+ and newer to fix the :c:macro: `Py_CLEAR ` macro which uses ``memcpy() ``. Patch
3+ by Victor Stinner.
You can’t perform that action at this time.
0 commit comments