Open
Description
Required prerequisites
- Make sure you've read the documentation. Your issue may be addressed there.
- Search the issue tracker and Discussions to verify that this hasn't already been reported. +1 or comment there if it has.
- Consider asking first in the Gitter chat room or in a Discussion.
What version (or hash if on master) of pybind11 are you using?
2.13.6
Problem description
#731 makes me believe that pybind11 should be able to handle returning nullptr for all data types, hence, I think this is an issue
Reproducible example code
(.venv-linux) sin3point14@DESKTOP-D97C2FN:~/random/cpp/pybind11-test$ cat main.cpp
#include <pybind11/pybind11.h>
#include <pybind11/eigen.h>
#include <pybind11/stl.h>
#include <Eigen/Eigen>
PYBIND11_MODULE(tsting, m)
{
m.def("ret_nullptr", []() -> Eigen::MatrixXd* {return nullptr;});
}
(.venv-linux) sin3point14@DESKTOP-D97C2FN:~/random/cpp/pybind11-test$ python3
Python 3.12.3 (main, Feb 4 2025, 14:48:35) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tsting
>>> tsting.ret_nullptr()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: PyCapsule_New called with null pointer
I get a segmentation fault in the project where I discovered this. But i guess this should also not have errored.
Is this a regression? Put the last known working version here if it is.
Not a regression