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
This commit is contained in:
Allan Leal
2018-10-11 10:28:12 +02:00
committed by Wenzel Jakob
parent 0f404a5d4d
commit e76dff7751
4 changed files with 22 additions and 1 deletions

View File

@@ -138,7 +138,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))
if (!isinstance<sequence>(src) || isinstance<str>(src))
return false;
auto s = reinterpret_borrow<sequence>(src);
value.clear();