Skip to content

Commit 06bb706

Browse files
committed
nanobind: numpy __version__ string->tuple conversion in UDF path
1 parent 82c6ebf commit 06bb706

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/duckdb_py/python_udf.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,10 @@ struct PythonUDFData {
523523
if (!numpy) {
524524
throw InvalidInputException("'numpy' is required for this operation, but it wasn't installed");
525525
}
526-
auto numpy_version = py::cast<py::tuple>(numpy.attr("__version__"));
526+
// numpy.__version__ is a string; pybind11's cast<py::tuple> converted it to a tuple of characters
527+
// (PySequence_Tuple). nanobind's cast<py::tuple> would reject a non-tuple, so convert explicitly.
528+
py::object numpy_version_str = numpy.attr("__version__");
529+
auto numpy_version = py::tuple(numpy_version_str);
527530
if (NumpyDeprecatesAccessToCore(numpy_version)) {
528531
core = numpy.attr("_core");
529532
} else {

0 commit comments

Comments
 (0)