I'm trying to use protobuf with PyPy and I've been quite successful doing so with cppyy. I generated the protobuf in C++ and used reflex to generate the bindings. I've encountered some problems that I don't know how to deal with and the documentation doesn't describe what you can do to resolve them.
I discovered that If you don't specify --deep when generating the reflex bindings and you try to pass a string to the C++ side you get a segfault. I'm guessing that's a bug. I can't catch exceptions that are being raised from C++ (it's also undocumented). I ensured that protobuf's FatalException has reflex bindings but the process crashes on an exception. e.SerializeAsString() [libprotobuf FATAL google/protobuf/message_lite.cc:273] CHECK failed: IsInitialized(): Can't serialize message of type "MyProtobufType" because it is missing required fields: header terminate called after throwing an instance of 'google::protobuf::FatalException' what(): CHECK failed: IsInitialized(): Can't serialize message of type "MyProtobufType" because it is missing required fields: header Aborted (core dumped) How can I catch that exception? The documentation is unclear how you can pass a pointer to a Python variable e.g.: str = "" e.SerializeToString(str) --------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-7-993880892d74> in <module>() ----> 1 e.SerializeToString(str) TypeError: none of the 5 overloaded methods succeeded. Full details: bool google::protobuf::MessageLite::SerializeToString(std::string*) => TypeError: cannot pass str as basic_string<char> bool google::protobuf::MessageLite::SerializeToString(std::string*) => TypeError: cannot pass str as basic_string<char> bool google::protobuf::MessageLite::SerializeToString(std::string*) => TypeError: cannot pass str as basic_string<char> bool google::protobuf::MessageLite::SerializeToString(std::string*) => TypeError: cannot pass str as basic_string<char> bool google::protobuf::MessageLite::SerializeToString(std::string*) => TypeError: cannot pass str as basic_string<char> Best Regards, Omer Katz.
_______________________________________________ pypy-dev mailing list pypy-dev@python.org https://mail.python.org/mailman/listinfo/pypy-dev