diff --git a/CMakeLists.txt b/CMakeLists.txt index 356cba2..1fdbd23 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ include(CPack) set(CMAKE_CXX_STANDARD 14) -add_compile_options(-pthread -Wall -Wextra -Wno-unused-parameter -Wno-deprecated-declarations) +add_compile_options(-pthread -Wall -Wextra -Wno-unused-parameter -Wno-deprecated-declarations -fvisibility=hidden) add_definitions(-DJUCI_VERSION="${JUCI_VERSION}") if(CMAKE_BUILD_TYPE STREQUAL "") add_compile_options(-O3) diff --git a/src/python_type_casters.h b/src/python_type_casters.h index 42d0503..69e1c6a 100644 --- a/src/python_type_casters.h +++ b/src/python_type_casters.h @@ -9,12 +9,19 @@ namespace pybind11 { public: PYBIND11_TYPE_CASTER(boost::filesystem::path, _("str")); bool load(handle src, bool) { - value = std::string(pybind11::str(src)); + if (!src) { + return false; + } + try { + value = std::string(py::str(src)); + } catch(...) { + return false; + } return !PyErr_Occurred(); } static handle cast(boost::filesystem::path src, return_value_policy, handle) { - return pybind11::str(src.string()); + return pybind11::str(src.string()).release(); } }; } // namespace detail