Skip to content

Handle none-type objects during casting#5

Open
FlyingSamson wants to merge 1 commit into
dlr-sp:mainfrom
FlyingSamson:allow-none-type-object-in-conversion
Open

Handle none-type objects during casting#5
FlyingSamson wants to merge 1 commit into
dlr-sp:mainfrom
FlyingSamson:allow-none-type-object-in-conversion

Conversation

@FlyingSamson

Copy link
Copy Markdown

Pybind11 allows to pass NoneType python objects to wrapped functions which will end up being passed as nullptrs to the underlying c++ function. See https://pybind11.readthedocs.io/en/stable/advanced/functions.html#allow-prohibiting-none-arguments.

For this to also work with swigbound types, the conversion of NoneType objects must be handled specially. The code in this PR was inspired by pybind11's internal handling of NoneTypes in its type_caster: https://github.com/pybind/pybind11/blob/master/include/pybind11/cast.h#L376-L422

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant