MCPcopy Create free account
hub / github.com/apache/arrow / WrapResult

Function WrapResult

python/pyarrow/src/arrow/python/common.h:90–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88/// \return A new Python reference, or NULL if an exception occurred
89template <typename T, typename PyWrapper = PyObject* (*)(T)>
90PyObject* WrapResult(Result<T> result, PyWrapper&& py_wrapper) {
91 static_assert(std::is_same_v<PyObject*, decltype(py_wrapper(std::declval<T>()))>,
92 "PyWrapper argument to WrapResult should return a PyObject* "
93 "when called with a T*");
94 Status st = result.status();
95 if (st.ok()) {
96 PyObject* py_value = py_wrapper(result.MoveValueUnsafe());
97 st = CheckPyError();
98 if (st.ok()) {
99 return py_value;
100 }
101 Py_XDECREF(py_value); // should be null, but who knows
102 }
103 // Status is an error, convert it to an exception.
104 return internal::convert_status(st);
105}
106
107// A RAII-style helper that ensures the GIL is acquired inside a lexical block.
108class ARROW_PYTHON_EXPORT PyAcquireGIL {

Callers 4

BindFutureFunction · 0.85
CallMethod · 0.85
ExecMethod · 0.85
ExecChunkedMethod · 0.85

Calls 5

CheckPyErrorFunction · 0.85
convert_statusFunction · 0.85
MoveValueUnsafeMethod · 0.80
statusMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected