WillAyd opened a new issue, #39572:
URL: https://github.com/apache/arrow/issues/39572

   ### Describe the bug, including details regarding any error messages, 
version, and platform.
   
   I am trying to use the new [PyCapsule 
Interface](https://arrow.apache.org/docs/format/CDataInterface/PyCapsuleInterface.html)
 to pass some object from Python to a C++ nanobind extension. The extension 
code looks as follows:
   
   ```cpp
   #include <nanobind/nanobind.h>
   #include "nanoarrow/nanoarrow.h"
   
   namespace nb = nanobind;
   
   void some_function(nb::object table) {
     auto arrow_c_stream = nb::getattr(table, "__arrow_c_stream__")();
     PyObject *obj = arrow_c_stream.ptr();
     if (!PyCapsule_CheckExact(obj)) {
       throw std::invalid_argument("Object does not provide capsule");
     }
   
     auto stream = static_cast<struct 
ArrowArrayStream*>(PyCapsule_GetPointer(obj, "arrow_array_stream"));
     struct ArrowSchema schema;
     if (!stream->get_schema(stream, &schema)) {
       //std::string errMsg{stream->get_last_error(stream)};
       throw std::runtime_error("Could not read from arrow schema:");
     }
   }
   
   NB_MODULE(somelib, m) {
     m.def("some_function", &some_function, nb::arg("table"));
   }
   ```
   
   Whenever this is called it always ends up throwing a runtime error. 
`stream->get_last_error(stream)` is also null.
   
   For anyone trying to reproduce here is a minimal project to work from:
   
   https://github.com/WillAyd/capsule-capi-testing/tree/main
   
   Am I missing something simple or is the capsule not properly providing an 
array stream here?
   
   ### Component(s)
   
   C++, Python


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to