github current snapshot

parent 028812ae
......@@ -144,7 +144,7 @@ template <typename Type, typename Value> struct list_caster {
using value_conv = make_caster<Value>;
bool load(handle src, bool convert) {
if (!isinstance<sequence>(src) || isinstance<str>(src))
if (!isinstance<sequence>(src) || (!isinstance<bytes>(src) && isinstance<str>(src)))
return false;
auto s = reinterpret_borrow<sequence>(src);
value.clear();
......
......@@ -291,6 +291,9 @@ TEST_SUBMODULE(stl, m) {
m.def("func_with_string_or_vector_string_arg_overload", [](std::list<std::string>) { return 2; });
m.def("func_with_string_or_vector_string_arg_overload", [](std::string) { return 3; });
// #1807: 2.3.0 regression: <class 'bytes'> is not converted to std::vector<uint8_t> anymore
m.def("func_with_vector_uint8_t_arg", [](std::vector<uint8_t> v) { return v.size(); });
class Placeholder {
public:
Placeholder() { print_created(this); }
......
......@@ -245,6 +245,13 @@ def test_function_with_string_and_vector_string_arg():
assert m.func_with_string_or_vector_string_arg_overload("A") == 3
def test_bytes_to_vector_uint8_t():
"""Check if a bytes is implicitly converted to std::vector<uint8_t>, issue #1807"""
assert m.func_with_vector_uint8_t_arg(b'abc') == 3
with pytest.raises(TypeError):
m.func_with_vector_uint8_t_arg('stringval')
def test_stl_ownership():
cstats = ConstructorStats.get(m.Placeholder)
assert cstats.alive() == 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment