Files
test2/source/blender/python/generic/python_compat.hh
Campbell Barton d9f38fca5f PyAPI: support Python 3.13
- `_PySet_NextEntry` has been removed, use generic iterator access
  which will has some additional overhead as it needs to create
  an iterator to access the values.

- Add v3.13 compatibility defines to account for renaming:
  _PyObject_LookupAttr -> PyObject_GetOptionalAttr
  _PyLong_AsInt -> PyLong_AsInt

- Unfortunately use of Python's internal API needs to be used to
  inspect op-codes in `bpy_driver.cc`.

Testing GLTF/FBX IO there isn't any significant performance impact
from these changes.

Resolves #123871.
2024-10-18 17:22:09 +11:00

26 lines
645 B
C++

/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup pygen
* \brief header-only compatibility defines.
*/
#pragma once
/* Removes `intialized` member from Python 3.13+. */
#if PY_VERSION_HEX >= 0x030d0000
# define PY_ARG_PARSER_HEAD_COMPAT()
#elif PY_VERSION_HEX >= 0x030c0000
/* Add `intialized` member for Python 3.12+. */
# define PY_ARG_PARSER_HEAD_COMPAT() 0,
#else
# define PY_ARG_PARSER_HEAD_COMPAT()
#endif
/* Python 3.13 made some changes, use the "new" names. */
#if PY_VERSION_HEX < 0x030d0000
# define PyObject_GetOptionalAttr _PyObject_LookupAttr
#endif