Hi,

2015-01-20 14:14 GMT+01:00 Omer Katz <omer.d...@gmail.com>:

> The documentation is unclear how you can pass a pointer to a Python
> variable e.g.:
> str = ""
>
> e.SerializeToString(str)
>

Message::SerializeToString() updates its argument in-place, but Python
strings are not mutable.
You should allocate a std::string from Python code, and pass it to the
function.
Maybe something like:

s = cppyy.gbl.std.string()
e.SerializeToString(s)
print s




> ---------------------------------------------------------------------------
> 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
>
>


-- 
Amaury Forgeot d'Arc
_______________________________________________
pypy-dev mailing list
pypy-dev@python.org
https://mail.python.org/mailman/listinfo/pypy-dev

Reply via email to