Fix seg fault using Python 2 invalid utf-8 strings and wstring

Fixes seg fault when passing a Python string, containing invalid utf-8 content,
to a wstring or wchar * parameter.  A TypeError is thrown instead, eg:

  %include <std_wstring.i>
  void instring(const std::wstring& s);

  instring(b"h\xe9llooo") # Python
This commit is contained in:
William S Fulton 2018-06-15 19:14:52 +01:00
commit e96316bf31
5 changed files with 57 additions and 4 deletions

View file

@ -6501,6 +6501,7 @@ void instring(const char *s) {
</pre></div>
<p>
Note that "\xe9" is an invalid UTF-8 encoding, but "\xc3\xb6" is valid.
When this method is called from Python 3, the return value is the following
text string:
</p>