Unsound call of set_var (#1664)

* refactor: lift cloning to caller

* refactor: do not elide lifetimes as in Rust 2018

* fix: unsound use of env::set_var, was breaking stdlib change to make unsafe

It is generally not safe to set env variables. The correct way to set a config
value that needs to be overridden is to hold a copy internal to the library and
only read from the environment.
This commit is contained in:
sftse
2024-10-25 15:44:30 +02:00
committed by GitHub
parent a8738a95d1
commit 6ea758872d
6 changed files with 33 additions and 13 deletions

View File

@ -553,7 +553,7 @@ impl tk::tokenizer::Normalizer for CustomNormalizer {
Python::with_gil(|py| {
let normalized = PyNormalizedStringRefMut::new(normalized);
let py_normalized = self.inner.bind(py);
py_normalized.call_method("normalize", (normalized.get(),), None)?;
py_normalized.call_method("normalize", (normalized.get().clone(),), None)?;
Ok(())
})
}