pythonize icon indicating copy to clipboard operation
pythonize copied to clipboard

Treat `NoneType` fields as `None`/missing during deserialization of mappings

Open tamasfe opened this issue 11 months ago • 0 comments
trafficstars

MCVE:

Rust side:

#[derive(Deserialize)]
struct Foo {
  #[serde(default)]
  foo: bool,
}

python side:

foo = {
  "foo": None,
}

depythonize::<Foo>(...) will fail with unexpected type: 'NoneType' object cannot be converted to '...'. However {} as input will work.

As far as I've looked, a check might be missing around here: https://github.com/davidhewitt/pythonize/blob/4491cdb46f35ab3fc1b419beef92171fbef510da/src/de.rs#L450 If that's the case I can look into it open PR with the fix.

tamasfe avatar Dec 10 '24 18:12 tamasfe