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

Function SafeCallIntoPython

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

Source from the content-addressed store, hash-verified

150// The GIL is acquired, and the current thread's error status is preserved.
151template <typename Function>
152auto SafeCallIntoPython(Function&& func) -> decltype(func()) {
153 PyAcquireGIL lock;
154 PyObject* exc_type;
155 PyObject* exc_value;
156 PyObject* exc_traceback;
157 PyErr_Fetch(&exc_type, &exc_value, &exc_traceback);
158 auto maybe_status = std::forward<Function>(func)();
159 // If the return Status is a "Python error", the current Python error status
160 // describes the error and shouldn't be clobbered.
161 if (!IsPyError(::arrow::ToStatus(maybe_status)) && exc_type != NULLPTR) {
162 PyErr_Restore(exc_type, exc_value, exc_traceback);
163 }
164 return maybe_status;
165}
166
167template <typename Function>
168auto SafeCallIntoPythonVoid(Function&& func) -> decltype(func()) {

Callers 15

type_nameMethod · 0.85
EqualsMethod · 0.85
GetFileInfoMethod · 0.85
CreateDirMethod · 0.85
DeleteDirMethod · 0.85
DeleteDirContentsMethod · 0.85
DeleteRootDirContentsMethod · 0.85
DeleteFileMethod · 0.85
MoveMethod · 0.85
CopyFileMethod · 0.85
OpenInputStreamMethod · 0.85
OpenInputFileMethod · 0.85

Calls 3

IsPyErrorFunction · 0.85
ToStatusFunction · 0.85
funcFunction · 0.50

Tested by

no test coverage detected