From b6cff9c712c18283983612c9acbbcdb7a3cde5d7 Mon Sep 17 00:00:00 2001 From: shadow_walker Date: Sun, 22 Oct 2017 20:21:17 -0500 Subject: [PATCH] patch from boost PR, https://github.com/boostorg/python/pull/54/ --- boost_string_to_byte.patch | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 boost_string_to_byte.patch diff --git a/boost_string_to_byte.patch b/boost_string_to_byte.patch new file mode 100644 index 0000000000..8415b69355 --- /dev/null +++ b/boost_string_to_byte.patch @@ -0,0 +1,28 @@ +From 8a49c161d39f4e77aac2556c644022c455f47c75 Mon Sep 17 00:00:00 2001 +From: centerionware +Date: Wed, 3 Feb 2016 22:17:40 -0700 +Subject: [PATCH] Change String handlign in Python 3 to byte type + +The byte type allows raw binary data to be passed in from std::strings. +It becomes necessary in the python to .decode('utf-8') in most cases, +but allows the programmer to make the choice as to when and where the +text is encoded in python instead of it being assumed it always need be. +Use case - passing binary in a std::string containing 0xff and other hex +to python, passing byte object from python to c++ std::string. +--- + include/boost/python/converter/builtin_converters.hpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/include/boost/python/converter/builtin_converters.hpp b/include/boost/python/converter/builtin_converters.hpp +index c2e01c03d..6c3ee2101 100644 +--- a/include/boost/python/converter/builtin_converters.hpp ++++ b/include/boost/python/converter/builtin_converters.hpp +@@ -155,7 +155,7 @@ BOOST_PYTHON_TO_PYTHON_BY_VALUE(unsigned BOOST_PYTHON_LONG_LONG, ::PyLong_FromUn + #if PY_VERSION_HEX >= 0x03000000 + BOOST_PYTHON_TO_PYTHON_BY_VALUE(char, converter::do_return_to_python(x), &PyUnicode_Type) + BOOST_PYTHON_TO_PYTHON_BY_VALUE(char const*, converter::do_return_to_python(x), &PyUnicode_Type) +-BOOST_PYTHON_TO_PYTHON_BY_VALUE(std::string, ::PyUnicode_FromStringAndSize(x.data(),implicit_cast(x.size())), &PyUnicode_Type) ++BOOST_PYTHON_TO_PYTHON_BY_VALUE(std::string, ::PyBytes_FromStringAndSize(x.data(),implicit_cast(x.size())), &PyByteArray_Type) + #else + BOOST_PYTHON_TO_PYTHON_BY_VALUE(char, converter::do_return_to_python(x), &PyString_Type) + BOOST_PYTHON_TO_PYTHON_BY_VALUE(char const*, converter::do_return_to_python(x), &PyString_Type)