Skip to content

Commit 5a7a5f8

Browse files
committed
Fix definition of PyTuple_SET_ITEM
1. It was missing the casts 2. The do-while trips up some weird C++ in scipy that uses it in a comma expression
1 parent 4763402 commit 5a7a5f8

File tree

1 file changed

+2
-3
lines changed
  • graalpython/com.oracle.graal.python.cext/include/cpython

1 file changed

+2
-3
lines changed

graalpython/com.oracle.graal.python.cext/include/cpython/tupleobject.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,9 @@ PyAPI_FUNC(PyObject *) _PyTuple_GET_ITEM(PyObject *, Py_ssize_t);
3939
// GraalPy-specific
4040
PyAPI_FUNC(PyObject **) PyTruffleTuple_GetItems(PyObject *op);
4141

42-
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
42+
// GraalPy change: Export PyTuple_SET_ITEM as regular API function to use in PyO3 and others
4343
PyAPI_FUNC(void) PyTuple_SET_ITEM(PyObject*, Py_ssize_t, PyObject*);
4444
#define PyTuple_SET_ITEM(op, index, value) \
45-
do { PyTruffleTuple_GetItems(op)[index] = value; } while (0)
46-
#endif
45+
PyTuple_SET_ITEM(_PyObject_CAST(op), (index), _PyObject_CAST(value))
4746

4847
PyAPI_FUNC(void) _PyTuple_DebugMallocStats(FILE *out);

0 commit comments

Comments
 (0)