2019-10-22 22:38:13 +00:00
|
|
|
use pyo3::prelude::*;
|
|
|
|
|
|
|
|
mod common;
|
|
|
|
|
|
|
|
#[pyfunction]
|
2021-02-11 21:37:38 +00:00
|
|
|
fn take_str(_s: &str) {}
|
2019-10-22 22:38:13 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_unicode_encode_error() {
|
|
|
|
let gil = Python::acquire_gil();
|
|
|
|
let py = gil.python();
|
|
|
|
|
2020-09-03 13:48:32 +00:00
|
|
|
let take_str = wrap_pyfunction!(take_str)(py).unwrap();
|
2020-10-13 21:38:21 +00:00
|
|
|
py_expect_exception!(
|
2019-10-22 22:38:13 +00:00
|
|
|
py,
|
|
|
|
take_str,
|
2020-10-13 21:38:21 +00:00
|
|
|
"take_str('\\ud800')",
|
|
|
|
PyUnicodeEncodeError,
|
|
|
|
"'utf-8' codec can't encode character '\\ud800' in position 0: surrogates not allowed"
|
2019-10-22 22:38:13 +00:00
|
|
|
);
|
|
|
|
}
|