I followed earlier advice for porting protobuf to Python 3.1 and I'm
pretty close to having the SVN trunk version working. Of the 174 tests
in "setup.py test", I have 4 failures and 10 errors that I'm still
working on.
I made the changes to protoc to add a Python3 output as was earlier
recommended. It fixes the metaclass issue and removes the calls to
unicode as previously recommended.
I installed "distribute" to get the "setuptools" stuff to work
properly ("distribute" is a Python3 compatible "clone" of "setuptools"
as previously mentioned).
I'm also attempting to make it specifically use "str" and "bytes"
types as opposed to just "str" for everything. My motivation is to
avoid the whole question of "is this string a string or is it really a
byte array?". I think I've got most of that sorted out (byte arrays in
the Python API have to specifically be set with something like
b'value' for instance). Is this a good idea or a bad idea? Internally
anything that's bytes I want to store as bytes, but perhaps I should
still allow setting it via a str assignment? This makes some of the
tests a bit weird to sort out if I do (there's one that makes sure you
can't set a "bytes" value as unicode(...) for instance).
My last area of concern is "text_format.py". I assume that I really
don't want to break the text representation here. Currently I have
protoc writing out the serialized proto in the Python classes as a
bytes value (b'...'), but I'm guessing that's a bad idea, since the
serialized ".proto" should always remain "text" even if it's stored in
a Python class? I know I have to handle text for all of the functions
for merging in .proto and text representations of proto. I think all
of the above 14 problems (4 failures and 10 errors) can be traced to
either _CEscape and _CUnescape so they should be my last two methods
to figure out (the whole lack of decode('string_escape') is making it
fun to figure out).
I'm pretty new to Python (more of a C#/Java/C++ in that order kind of
guy), so I can't promise it's optimal in content or performance, but I
need a Python3 version of protobuf for use in Blender 2.5 (Python3
API).
-Kent
--
You received this message because you are subscribed to the Google Groups
"Protocol Buffers" group.
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.