File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -235,7 +235,7 @@ def test_pybind11_str_raw_str():
235
235
# specifically to exercise pybind11::str::raw_str
236
236
cvt = m .convert_to_pybind11_str
237
237
assert cvt (u"Str" ) == u"Str"
238
- assert cvt (b" Bytes" ) == u"Bytes" if str is bytes else "b'Bytes'"
238
+ assert cvt (b' Bytes' ) == u"Bytes" if str is bytes else "b'Bytes'"
239
239
assert cvt (None ) == u"None"
240
240
assert cvt (False ) == u"False"
241
241
assert cvt (True ) == u"True"
@@ -251,6 +251,16 @@ def test_pybind11_str_raw_str():
251
251
assert cvt (set ()) == u"set([])" if str is bytes else "set()"
252
252
assert cvt ({3 , 3 }) == u"set([3])" if str is bytes else "{3}"
253
253
254
+ valid_utf8 = u"DZ" .encode ("utf-8" )
255
+ valid_cvt = cvt (valid_utf8 )
256
+ assert type (valid_cvt ) == bytes # Probably surprising.
257
+ assert valid_cvt == b'\xc7 \xb1 '
258
+
259
+ malformed_utf8 = b'\x80 '
260
+ malformed_cvt = cvt (malformed_utf8 )
261
+ assert type (malformed_cvt ) == bytes # Probably surprising.
262
+ assert malformed_cvt == b'\x80 '
263
+
254
264
255
265
def test_implicit_casting ():
256
266
"""Tests implicit casting when assigning or appending to dicts and lists."""
You can’t perform that action at this time.
0 commit comments