This will be fixed in 2.5.0, see issue 418 http://code.google.com/p/protobuf/issues/detail?id=418
On Tuesday, July 10, 2012 9:55:15 PM UTC-4, Alex Roper wrote: > > Hi, > > As part of a research project I'm working on, I found it convenient to be > able to pickle messages (or more specifically Python structures that > contain them). You can do this without patching protobuf, but it is a bit > clumsier and (unless I'm missing something) requires registering a handler > for every kind of message to be handled with copy_reg, or breaking down the > structures manually (especially annoying when operating interactively). > > The attached patch adds __getstate__ and __setstate__ methods to generated > classes, hooking into pickle and using SerializePartialToString to return > an object pickle knows how to deal with, allowing them to be pickled out of > the box. This seems to work for both standard Python messages and the > experimental C++ bindings. > > I'm not sure whether this is a common use case, but it solved my problem > nicely, and seems like something that should just work, and therefore I > contribute it upstream. > > Alex > -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To view this discussion on the web visit https://groups.google.com/d/msg/protobuf/-/PYT5QFI2HIMJ. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.
