birkenfeld / serde-pickle

Rust (de)serialization for the Python pickle format.
Apache License 2.0
188 stars 28 forks source link

Bigints cannot be parsed #23

Closed njaard closed 1 year ago

njaard commented 1 year ago

If I pickle a bigint in python:

import pickle
d=123238476387643857365837465
#d=1234
with open('data.pickle', 'wb') as f:
        pickle.dump(d, f, pickle.HIGHEST_PROTOCOL)

And then try to parse it with serde-pickle:

fn main()
{
  let mut m = std::io::BufReader::new(std::fs::File::open("data.pickle").unwrap());

  let v: serde_pickle::value::Value = serde_pickle::from_reader(
    &mut m, std::default::Default::default()
  ).unwrap();
  dbg!(v);
}

It cannot be loaded:


thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Syntax(InvalidValue("integer too large"))', src/main.rs:7:5
njaard commented 1 year ago

One needs to use value_from_reader