jsonpickle: jsonpickle 2.0.0 fails to decode pickled files created by jsonpickle 1.4.1

I’ve been attempting to upgrade the jsonpickle package in our project, where we store a number of files in pickled format. It happens that in some UTs for that area their evaluation failed, when I only change the jsonpickle package to 2.0.0. For 1.5.2 it still works. I also locally tested with the real data, in case it would be case of overly specific UTs. But those ended up with corrupted JSON data. As one can see in the screenshotRampdown-pickle-issue, instead of

"previousFeatureTeam": {
        "py/id": 1
      },

on the left side created with 1.5.2, the version created by jsonpickle suddenly creates a list and effectively doubles the output by reusing existing data (but even that seems corrupted).

I suspect that the format changed or that maybe 2.0.0 introduced a regression, but I couldn’t find any information on what actually changed for 2.0.0. Do I need to do something special for conversions from older data?

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (10 by maintainers)

Commits related to this issue

Most upvoted comments

Small update: I believe it’s possible to fix this by adding a compatibility mode to the Unpickler.restore_dict method that controls whether a function is called or not. Specifically, this line: https://github.com/jsonpickle/jsonpickle/blob/a15517ee97e65908d1b2cfeca40c08ad1028c973/jsonpickle/unpickler.py#L545 Adding an option to toggle it on or off would allow the unpickler to switch between v2 behavior or v1 behavior for unpickling, and then the data could be re-encoded in the v2 format.

However, I want to preemptively state that I don’t think it’s a good idea to modify the pickler to allow encoding in the v1 format because enabling this current behavior fixed #255. Thoughts @davvid?