Add .none(false) for arguments of python exposed functions expecting strings
Several API functions are taking const char * parameters. They are often exposed to Python with: .def("function", &Class::function, "parameter"_a) This is working fine, when used in python, the parameter type is checked, but when used with None a segfault occurs. To handle that .none(false) can be added to the parameter: .def("function", &Class::function, "parameter"_a.none(false))
May I work on this or is this resolved in a recent PR?
@EmperorYP7 Thanks to volunteer to work the issue. It only requires some Python knowledge. But I thought you wanted to work on the OpenFX plugin?
That's right @hodoulp sir, I am currently working on OFX plugins but am also curious about this. If someone wants to work on this now, they're welcomed! :smile:
May I work on this issue?
For example, this would crash: cfg = OCIO.Config.CreateRaw() cfg.getColorSpace(None)
As @divshekhar noticed it is also the case for shared pointers.
When binding a function that takes char * as parameter, automatic binding would expect a string but None is not allowed and should be excluded with none(false) if the function is bound directly.
If the binding is done with a function using std::string None would be handled (ex: def_static("CreateFromStream", [](const std::string & str)).
Other type, like ints, enums etc are already handling None.
Situation in ensure with shared pointers (empty shared pointers as parameter can be an issue for the API).
This issue is still open, but requires some experience with pybind.