Re: [protobuf] How to serialize in C++ for parsing in Python

2020-10-15 Thread Randy Nuss
I solved this. It did require the Python caller obtaining the string size from the C++ DLL. The key part is to use ctypes.string_at() to then define the string at the Python end. lib.fun.argtypes = [c_void_p, c_void_p] lib.fun.restype = c_void_p size = c_int() return_ptr = lib.fun(self.obj, b

Re: [protobuf] How to serialize in C++ for parsing in Python

2020-10-14 Thread 'Adam Cozzette' via Protocol Buffers
I think if you have to work with C types then you will need to provide both a char* and an integer length. That Python error makes it sound like the Python code is probably trying to parse beyond the end of the serialized message. On Wed, Oct 14, 2020 at 3:55 PM Randy Nuss wrote: > I am building

[protobuf] How to serialize in C++ for parsing in Python

2020-10-14 Thread Randy Nuss
I am building a C++ library with protobuf messages for consumption by a Python program. The issue is SerializeToString() takes std::string, but only c_types (like char*) can be exported by the dll, which results in numerical zeros being recognized as string terminators and truncating the Parse