-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] py::type
constructor from object
does not throw when passed a non-type object
#2700
Comments
Additional explanation: I think we decided in that PR (#2364) that |
Minimal reproducer: #include <pybind11/pybind11.h>
namespace py = pybind11;
PYBIND11_MODULE(example, m) {
py::print(py::type(py::cast(int{})));
} EDIT: Even minimal-er example #include <pybind11/pybind11.h>
namespace py = pybind11;
PYBIND11_MODULE(example, m) {
py::print(py::type(py::int_()));
} |
Got it: pybind11/include/pybind11/pytypes.h Lines 825 to 826 in 028812a
Checking the value of the |
Issue description
py::type(object)
constructor is returning an instance, which is unexpected.This report was suggested by @YannickJadoul in gitter: https://gitter.im/pybind/Lobby?at=5fc11de4b12c2622f909e92f
Reproducible example code
After changing
pybind11::type(
forpybind11::type::of(
the result is the correct<class 'int'>
The text was updated successfully, but these errors were encountered: