mirror of
https://github.com/pybind/pybind11.git
synced 2026-05-05 14:11:43 +00:00
Make string conversion stricter (#695)
* Make string conversion stricter The string conversion logic added in PR #624 for all std::basic_strings was derived from the old std::wstring logic, but that was underused and turns out to have had a bug in accepting almost anything convertible to unicode, while the previous std::string logic was much stricter. This restores the previous std::string logic by only allowing actual unicode or string types. Fixes #685. * Added missing 'requires numpy' decorator (I forgot that the change to a global decorator here is in the not-yet-merged Eigen PR)
This commit is contained in:
committed by
Wenzel Jakob
parent
dd01665e5a
commit
ee2e5a5086
@@ -272,3 +272,12 @@ def test_constructors():
|
||||
assert results["array"].dtype == np.int_
|
||||
assert results["array_t<int32>"].dtype == np.int32
|
||||
assert results["array_t<double>"].dtype == np.float64
|
||||
|
||||
|
||||
@pytest.requires_numpy
|
||||
def test_greedy_string_overload(): # issue 685
|
||||
from pybind11_tests.array import issue685
|
||||
|
||||
assert issue685("abc") == "string"
|
||||
assert issue685(np.array([97, 98, 99], dtype='b')) == "array"
|
||||
assert issue685(123) == "other"
|
||||
|
||||
Reference in New Issue
Block a user