We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversion from bytes() from python to std::string should be automatic according to the documentation at: http://pybind11.readthedocs.io/en/master/advanced/cast/strings.html#passing-bytes-to-c
However, when I actually have a function that accepts std::string, passing a bytes object causes a TypeError.
python 3.4.2 pybind11 git hash deb85f4 gcc: arm-linux-gnueabihf-gcc ( 4.9.2-10) 4.9.2
With py::bytes also being available, I'm not sure if this is a bug in the code or an error in the documentation.
#include <pybind11/pybind11.h> namespace py = pybind11; void test(const std::string& s) { } PYBIND11_PLUGIN(example) { py::module m("example", "pybind11 example plugin"); m.def("test", &test, ""); return m.ptr(); }
import example example.test('x') # works example.test(b'x') # TypeError
The text was updated successfully, but these errors were encountered:
Definitely looks like a bug. (I also just checked--it doesn't affect Python 2, where it would probably be much more noticeable)
Sorry, something went wrong.
bytes
No branches or pull requests
Issue description
Conversion from bytes() from python to std::string should be automatic according to the documentation at:
http://pybind11.readthedocs.io/en/master/advanced/cast/strings.html#passing-bytes-to-c
However, when I actually have a function that accepts std::string, passing a bytes object causes a TypeError.
python 3.4.2
pybind11 git hash deb85f4
gcc: arm-linux-gnueabihf-gcc ( 4.9.2-10) 4.9.2
With py::bytes also being available, I'm not sure if this is a bug in the code or an error in the documentation.
Reproducible example code
The text was updated successfully, but these errors were encountered: