Fix for Issue #1258 (#1298)
* Fix for Issue #1258
list_caster::load method will now check for a Python string and prevent its automatic conversion to a list.
This should fix the issue "pybind11/stl.h converts string to vector<string> #1258" (https://github.com/pybind/pybind11/issues/1258)
* Added tests for fix of issue #1258
* Changelog: stl string auto-conversion
diff --git a/tests/test_stl.py b/tests/test_stl.py
index 2c5e995..b78f86a 100644
--- a/tests/test_stl.py
+++ b/tests/test_stl.py
@@ -201,6 +201,14 @@
assert expected_message in str(excinfo.value)
+def test_function_with_string_and_vector_string_arg():
+ """Check if a string is NOT implicitly converted to a list, which was the
+ behavior before fix of issue #1258"""
+ assert m.func_with_string_or_vector_string_arg_overload(('A', 'B', )) == 2
+ assert m.func_with_string_or_vector_string_arg_overload(['A', 'B']) == 2
+ assert m.func_with_string_or_vector_string_arg_overload('A') == 3
+
+
def test_stl_ownership():
cstats = ConstructorStats.get(m.Placeholder)
assert cstats.alive() == 0