pyo3/tests/test_string.rs
Icxolu ee89b2e8e2
deprecate wrap_pyfunction with py argument (#3954)
* deprecate `wrap_pyfunction` with `py` argument

The Python token in `wrap_pyfunction` is not handled automatically by
`WrapPyFunctionArg`, for backwards compatibility. This uses deref
specialization to deprecate this variant.

* merge `Extractor`s

* add deprecation ui test, revert closure variant due to test failure

* fix nightly
2024-03-12 22:57:03 +00:00

24 lines
536 B
Rust

#![cfg(feature = "macros")]
use pyo3::prelude::*;
#[path = "../src/tests/common.rs"]
mod common;
#[pyfunction]
fn take_str(_s: &str) {}
#[test]
fn test_unicode_encode_error() {
Python::with_gil(|py| {
let take_str = wrap_pyfunction_bound!(take_str)(py).unwrap();
py_expect_exception!(
py,
take_str,
"take_str('\\ud800')",
PyUnicodeEncodeError,
"'utf-8' codec can't encode character '\\ud800' in position 0: surrogates not allowed"
);
});
}