| 31 | namespace csv { |
| 32 | |
| 33 | InvalidRowHandler MakeInvalidRowHandler(PyInvalidRowCallback cb, PyObject* py_handler) { |
| 34 | if (cb == nullptr) { |
| 35 | return InvalidRowHandler{}; |
| 36 | } |
| 37 | |
| 38 | struct Handler { |
| 39 | PyInvalidRowCallback cb; |
| 40 | std::shared_ptr<OwnedRefNoGIL> handler_ref; |
| 41 | |
| 42 | InvalidRowResult operator()(const InvalidRow& invalid_row) { |
| 43 | InvalidRowResult result; |
| 44 | auto st = SafeCallIntoPython([&]() -> Status { |
| 45 | result = cb(handler_ref->obj(), invalid_row); |
| 46 | if (PyErr_Occurred()) { |
| 47 | PyErr_WriteUnraisable(handler_ref->obj()); |
| 48 | } |
| 49 | return Status::OK(); |
| 50 | }); |
| 51 | ARROW_UNUSED(st); |
| 52 | return result; |
| 53 | } |
| 54 | }; |
| 55 | |
| 56 | Py_INCREF(py_handler); |
| 57 | return Handler{cb, std::make_shared<OwnedRefNoGIL>(py_handler)}; |
| 58 | } |
| 59 | |
| 60 | } // namespace csv |
| 61 | } // namespace py |
nothing calls this directly
no outgoing calls
no test coverage detected