mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-25 22:52:01 +00:00
11a337f16f
* Propagate unicode conversion failure If returning a std::string with invalid utf-8 data, we currently fail with an uninformative TypeError instead of propagating the UnicodeDecodeError that Python sets on failure. * Add support for u16/u32strings and literals This adds support for wchar{16,32}_t character literals and the associated std::u{16,32}string types. It also folds the character/string conversion into a single type_caster template, since the type casters for string and wstring were mostly the same anyway. * Added too-long and too-big character conversion errors With this commit, when casting to a single character, as opposed to a C-style string, we make sure the input wasn't a multi-character string or a single character with codepoint too large for the character type. This also changes the character cast op to CharT instead of CharT& (we need to be able to return a temporary decoded char value, but also because there's little gained by bothering with an lvalue return here). Finally it changes the char caster to 'has-a-string-caster' instead of 'is-a-string-caster' because, with the cast_op change above, there's nothing at all gained from inheritance. This also lets us remove the `success` from the string caster (which was only there for the char caster) into the char caster itself. (I also renamed it to 'none' and inverted its value to better reflect its purpose). The None -> nullptr loading also now takes place only under a `convert = true` load pass. Although it's unlikely that a function taking a char also has overloads that can take a None, it seems marginally more correct to treat it as a conversion. This commit simplifies the size assumptions about character sizes with static_asserts to back them up. |
||
---|---|---|
.. | ||
test_cmake_build | ||
CMakeLists.txt | ||
conftest.py | ||
constructor_stats.h | ||
object.h | ||
pybind11_tests.cpp | ||
pybind11_tests.h | ||
test_alias_initialization.cpp | ||
test_alias_initialization.py | ||
test_buffers.cpp | ||
test_buffers.py | ||
test_callbacks.cpp | ||
test_callbacks.py | ||
test_chrono.cpp | ||
test_chrono.py | ||
test_class_args.cpp | ||
test_class_args.py | ||
test_constants_and_functions.cpp | ||
test_constants_and_functions.py | ||
test_copy_move_policies.cpp | ||
test_copy_move_policies.py | ||
test_docstring_options.cpp | ||
test_docstring_options.py | ||
test_eigen.cpp | ||
test_eigen.py | ||
test_enum.cpp | ||
test_enum.py | ||
test_eval_call.py | ||
test_eval.cpp | ||
test_eval.py | ||
test_exceptions.cpp | ||
test_exceptions.py | ||
test_inheritance.cpp | ||
test_inheritance.py | ||
test_issues.cpp | ||
test_issues.py | ||
test_keep_alive.cpp | ||
test_keep_alive.py | ||
test_kwargs_and_defaults.cpp | ||
test_kwargs_and_defaults.py | ||
test_methods_and_attributes.cpp | ||
test_methods_and_attributes.py | ||
test_modules.cpp | ||
test_modules.py | ||
test_multiple_inheritance.cpp | ||
test_multiple_inheritance.py | ||
test_numpy_array.cpp | ||
test_numpy_array.py | ||
test_numpy_dtypes.cpp | ||
test_numpy_dtypes.py | ||
test_numpy_vectorize.cpp | ||
test_numpy_vectorize.py | ||
test_opaque_types.cpp | ||
test_opaque_types.py | ||
test_operator_overloading.cpp | ||
test_operator_overloading.py | ||
test_pickling.cpp | ||
test_pickling.py | ||
test_python_types.cpp | ||
test_python_types.py | ||
test_sequences_and_iterators.cpp | ||
test_sequences_and_iterators.py | ||
test_smart_ptr.cpp | ||
test_smart_ptr.py | ||
test_stl_binders.cpp | ||
test_stl_binders.py | ||
test_virtual_functions.cpp | ||
test_virtual_functions.py |