File tree Expand file tree Collapse file tree 4 files changed +6
-14
lines changed
Expand file tree Collapse file tree 4 files changed +6
-14
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,11 +139,6 @@ System includes
138139 * ``<errno.h> ``
139140 * ``<stdio.h> ``
140141 * ``<stdlib.h> ``
141- * ``<string.h> ``
142-
143- The ``<string.h> `` header is also included when using :ref: `Limited API
144- <limited-c-api>` 3.11 or newer if Python is unable to get a ``typeof() ``
145- implementation.
146142
147143.. note ::
148144
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 @@ -471,9 +471,6 @@ static inline Py_ALWAYS_INLINE void Py_DECREF(PyObject *op)
471471 * and so avoid type punning. Otherwise, use memcpy() which causes type erasure
472472 * and so prevents the compiler to reuse an old cached 'op' value after
473473 * Py_CLEAR().
474- *
475- * Include <string.h> if _Py_TYPEOF() is not available, since the limited C API
476- * version 3.11 and newer doesn't include it.
477474 */
478475#ifdef _Py_TYPEOF
479476#define Py_CLEAR (op ) \
@@ -486,7 +483,6 @@ static inline Py_ALWAYS_INLINE void Py_DECREF(PyObject *op)
486483 } \
487484 } while (0)
488485#else
489- #include <string.h> // memcpy()
490486#define Py_CLEAR (op ) \
491487 do { \
492488 PyObject **_tmp_op_ptr = _Py_CAST(PyObject**, &(op)); \
Original file line number Diff line number Diff line change 1- Fix the :c:macro: ` Py_CLEAR ` implementation in the limited C API version 3.11
2- and newer: include `` <string.h> `` to get the ``memcpy() `` function . Patch by
3- Victor Stinner.
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