Schilcote
Schilcote

Reputation: 2404

"pickle exhausted before end of frame" when using Dill with code that works fine with Pickle

I'm working on a game project that uses Pickle to implement savegames (I know the downsides of doing so - let's not discuss that here). This works excellently: unfortunately standard Pickle cannot handle some of the things I wish to do in future versions, so I'm transitioning to Dill instead. Unfortunately, it doesn't work: it gives _pickle.UnpicklingError: pickle exhausted before end of frame whenever it loads a save.

To reiterate: this code and the test cases I'm using work perfectly with Pickle. It only has issues with Dill.

I'm importing Dill like this:

try:
    import dill as pickle
except ImportError:
    print("Failed to load Dill serialization library: some features may not work correctly.")
    import pickle

And the full traceback is as such:

   Traceback (most recent call last):
  File "C:/Users/Schilcote/workspace/pyweek19/main.py", line 605, in game_init
    gamestate=pickle.load(open(os.path.join(_savedir,"save.sav"),"rb"))
  File "C:\Python34\lib\site-packages\dill\dill.py", line 199, in load
    obj = pik.load()
  File "C:\Python34\Lib\pickle.py", line 1036, in load
    dispatch[key[0]](self)
  File "C:\Python34\Lib\pickle.py", line 1321, in load_global
    module = self.readline()[:-1].decode("utf-8")
  File "C:\Python34\Lib\pickle.py", line 247, in readline
    "pickle exhausted before end of frame")
_pickle.UnpicklingError: pickle exhausted before end of frame

I don't know how to even begin diagnosing this. What's going on?

EDIT:

To clarify, the error comes upon deserialization.

Upvotes: 1

Views: 2606

Answers (1)

Peque
Peque

Reputation: 14831

Maybe you are (or you were) using CPython 3.4? If so, there was a bug that should be fixed already.

I also had this problem, not in my computer, which has Python 3.4.4, but with Github's Travis, which is using 3.4.2.

Upvotes: 1

Related Questions