Skip to content

Commit

Permalink
Remove id field in PyCodec clone
Browse files Browse the repository at this point in the history
  • Loading branch information
juntyr committed Jul 30, 2024
1 parent dbbeeef commit 1278042
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion crates/numcodecs-python/src/pycodec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use pyo3::{
exceptions::{PyIndexError, PyTypeError},
intern,
prelude::*,
types::{IntoPyDict, PyDict},
types::{IntoPyDict, PyDict, PyDictMethods},
};
use pythonize::{Depythonizer, Pythonizer};
use serde::{Deserializer, Serializer};
Expand Down Expand Up @@ -256,13 +256,18 @@ impl DynCodec for PyCodec {
}

impl Clone for PyCodec {
#[allow(clippy::expect_used)] // clone is *not* fallible
fn clone(&self) -> Self {
Python::with_gil(|py| {
let config = self
.codec
.bind(py)
.get_config()
.expect("getting codec config should not fail");

// removing the `id` field may fail if the config doesn't contain it
let _ = config.del_item(intern!(py, "id"));

let codec = self
.codec
.bind(py)
Expand Down

0 comments on commit 1278042

Please sign in to comment.