I am currently working on a similar issue, can you patch and check if
this CL can fix yours issue?
https://critique.corp.google.com/#review/163859531

On Thu, Aug 3, 2017 at 5:20 AM, Fenyx <chench...@gmail.com> wrote:
> hi guys,
>
> I am new to protobuf. I am doing some test projects here. The goal is very
> simple: create a message, fill content in the message using python, them
> dump the message to /home/centos as a text file, in the end, the text file
> will be load back to the message object in another python/c++ program. In a
> simple sense, using protobuf as an ASCII serialization media.
>
> However, when I try to read the ASCII content back to a python process, I
> run into the following problem. It complains that I need a bytes-like
> object. I use type() to check, the input was truly bytes.
>
> Does anyone know what is the issue?
>
> thanks!
>
>
> In [90]: text_format.Merge(b,read_config)
> ---------------------------------------------------------------------------
> TypeError                                 Traceback (most recent call last)
> <ipython-input-90-8bb6083b0038> in <module>()
> ----> 1 text_format.Merge(b,read_config)
>
> /home/centos/anaconda3/lib/python3.5/site-packages/google/protobuf/text_format.py
> in Merge(text, message, allow_unknown_extension, allow_field_number,
> descriptor_pool)
>     470   """
>     471   return MergeLines(
> --> 472       text.split('\n'),
>     473       message,
>     474       allow_unknown_extension,
>
> TypeError: a bytes-like object is required, not 'str'
>
> In [91]: type(b)
> Out[91]: bytes
>
> In [92]: b
> Out[92]: b'name: "A1"\nfactor_fe_config {\n  name:
> "style_slow"\n}\nfactor_fe_config {\n  name: "style_fast"\n}\n'
>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to protobuf+unsubscr...@googlegroups.com.
> To post to this group, send email to protobuf@googlegroups.com.
> Visit this group at https://groups.google.com/group/protobuf.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to