[pypy-dev] cppyy questions
Amaury Forgeot d'Arc
amauryfa at gmail.com
Tue Jan 20 14:40:45 CET 2015
Hi,
2015-01-20 14:14 GMT+01:00 Omer Katz <omer.drow at 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 at python.org
> https://mail.python.org/mailman/listinfo/pypy-dev
>
>
--
Amaury Forgeot d'Arc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20150120/0c33ffb6/attachment.html>
More information about the pypy-dev
mailing list