From d0325bbd9718d5318b90179f7eacc3a50d90d15b Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Sun, 17 Jan 2016 22:36:37 +0100 Subject: [PATCH] switched a few admissible cases from PyTuple_Set/GetItem -> PyTuple_SET/GET_ITEM --- include/pybind11/cast.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index a02f68fb..61ac1502 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -320,9 +320,9 @@ public: bool load(PyObject *src, bool convert) { if (!PyTuple_Check(src) || PyTuple_Size(src) != 2) return false; - if (!first.load(PyTuple_GetItem(src, 0), convert)) + if (!first.load(PyTuple_GET_ITEM(src, 0), convert)) return false; - return second.load(PyTuple_GetItem(src, 1), convert); + return second.load(PyTuple_GET_ITEM(src, 1), convert); } static PyObject *cast(const type &src, return_value_policy policy, PyObject *parent) { @@ -333,8 +333,8 @@ public: PyObject *tuple = PyTuple_New(2); if (!tuple) return nullptr; - PyTuple_SetItem(tuple, 0, o1.release()); - PyTuple_SetItem(tuple, 1, o2.release()); + PyTuple_SET_ITEM(tuple, 0, o1.release()); + PyTuple_SET_ITEM(tuple, 1, o2.release()); return tuple; } @@ -422,7 +422,7 @@ protected: return nullptr; int counter = 0; for (auto & result : results) - PyTuple_SetItem(tuple, counter++, result.release()); + PyTuple_SET_ITEM(tuple, counter++, result.release()); return tuple; } @@ -512,10 +512,10 @@ template inline object handle::call(Args&&... args_) const { throw cast_error("handle::call(): unable to convert input arguments to Python objects"); object tuple(PyTuple_New(size), false); if (!tuple) - throw cast_error("handle::call(): unable to convert input arguments to Python objects"); + throw cast_error("handle::call(): unable to allocate tuple"); int counter = 0; for (auto & result : args) - PyTuple_SetItem(tuple.ptr(), counter++, result.release()); + PyTuple_SET_ITEM(tuple.ptr(), counter++, result.release()); PyObject *result = PyObject_CallObject(m_ptr, tuple.ptr()); if (result == nullptr && PyErr_Occurred()) throw error_already_set();