Dear ROOTers,
I am having trouble getting arbitrary-length arrays of bytes (/strings containing null characters) into PyROOT. It appears to automatically cast char* and std::string into 'str' and void* to PyLongBuffer, assuming that the first null character encountered in the array is for termination and only copying up to there.
This is problematic since some ROOT functions, like TBufferFile::Buffer(), return char* arrays which should not be interpreted as strings. Calling that method in Python returns the first byte '@' (there should be more, but second byte is null), at which point it's too late to use TBufferFile::Length().
The TString class solves this problem by providing a constructor taking a char* and a size. Is there some wrapper function like that in PyROOT that I've overlooked, or is there some other way to get handle arrays/strings containing nulls?
Best,
Andy
Received on Wed Nov 23 2011 - 01:57:59 CET
This archive was generated by hypermail 2.2.0 : Thu Nov 24 2011 - 05:50:01 CET