diff --git a/test/comprehensive.py b/test/comprehensive.py index 7d0bec79..4aa951f3 100644 --- a/test/comprehensive.py +++ b/test/comprehensive.py @@ -1273,6 +1273,10 @@ import sys def run(args = None): if args is not None: sys.argv = args + + if hasattr(sys,'setdlopenflags'): + sys.setdlopenflags( 6 ) # dl.RTLD_NOW | dl.RTLD_GLOBAL) + import doctest, comprehensive return doctest.testmod(comprehensive) diff --git a/test/m1.cpp b/test/m1.cpp index 4aa81f36..42412c5d 100644 --- a/test/m1.cpp +++ b/test/m1.cpp @@ -10,9 +10,6 @@ #include #include #include -#include -#include -#include #include #include #include @@ -98,9 +95,7 @@ PyObject* new_simple() // // Declare some wrappers/unwrappers to test the low-level conversion -// mechanism. See boost/python/converter/source.hpp,target.hpp for a -// description of how the type parameters to wrapper<> and unwrapper<> -// are selected. +// mechanism. // using boost::python::to_python_converter; diff --git a/test/test_builtin_converters.cpp b/test/test_builtin_converters.cpp index 939f9dc4..2066e0f8 100644 --- a/test/test_builtin_converters.cpp +++ b/test/test_builtin_converters.cpp @@ -25,11 +25,14 @@ struct by_const_reference } }; +char const* rewrap_value_mutable_cstring(char* x) { return x; } + BOOST_PYTHON_MODULE_INIT(builtin_converters) { boost::python::module("builtin_converters") .def("rewrap_value_bool", by_value::rewrap) + .def("rewrap_value_char", by_value::rewrap) .def("rewrap_value_signed_char", by_value::rewrap) .def("rewrap_value_unsigned_char", by_value::rewrap) .def("rewrap_value_int", by_value::rewrap) @@ -47,8 +50,12 @@ BOOST_PYTHON_MODULE_INIT(builtin_converters) .def("rewrap_value_string", by_value::rewrap) .def("rewrap_value_cstring", by_value::rewrap) + // Expose this to illustrate our failings ;-). See test_builtin_converters.py + .def("rewrap_value_mutable_cstring", rewrap_value_mutable_cstring) + .def("rewrap_const_reference_bool", by_const_reference::rewrap) + .def("rewrap_const_reference_char", by_const_reference::rewrap) .def("rewrap_const_reference_signed_char", by_const_reference::rewrap) .def("rewrap_const_reference_unsigned_char", by_const_reference::rewrap) .def("rewrap_const_reference_int", by_const_reference::rewrap) diff --git a/test/test_builtin_converters.py b/test/test_builtin_converters.py index 3958c15a..8f7b5e58 100644 --- a/test/test_builtin_converters.py +++ b/test/test_builtin_converters.py @@ -6,6 +6,14 @@ 0 >>> rewrap_value_bool(33) 1 +>>> rewrap_value_char('x') +'x' + + Note that there's currently silent truncation of strings passed to + char arguments. + +>>> rewrap_value_char('xy') +'x' >>> rewrap_value_signed_char(42) 42 >>> rewrap_value_unsigned_char(42) @@ -42,12 +50,26 @@ >>> rewrap_value_string('yo, wassup?') 'yo, wassup?' + Note that we can currently get a mutable pointer into an immutable + Python string: + +>>> rewrap_value_mutable_cstring('hello, world') +'hello, world' + >>> rewrap_const_reference_bool(None) 0 >>> rewrap_const_reference_bool(0) 0 >>> rewrap_const_reference_bool('yes') 1 +>>> rewrap_const_reference_char('x') +'x' + + Note that there's currently silent truncation of strings passed to + char arguments. + +>>> rewrap_const_reference_char('xy') +'x' >>> rewrap_const_reference_signed_char(42) 42 >>> rewrap_const_reference_unsigned_char(42)