I believe you have a bug in your example, as str()
will format a bytes-containing object into a nonsensical file name, e.g., "b'/some/where'"
. That last line should read
loadVolume(os.fspath(file))
Given that, I’m guessing what you’re looking for is a change to the generated wrappers that automatically calls os.fspath
for all path-like arguments as described in PEP 519?
If so, have you made a list of the touch points within the VTK source code where this would be applied? That seems like it would be a good first step towards seeing if your idea is feasible.
Taking a cursory look at some of the code that opens files, I see a lot of generic const char *
declarations for file name parameters, meaning that this couldn’t be automated substantially, so would entail reading through all of VTK and somehow building a table of signatures to indicate where to call os.fspath
and where not to (which seems like a huge amount of work).