How to repair RenPy game save loading after renaming pickled python class?

There is a RenPy-based game that uses custom Python classes for some game objects. Recently we renamed some modules and classes as part of refactoring. This broke loading of old game saves because Pickle can't find classes.

The Pickle itself supports a mechanism to properly handle situation with class renaming:

However I can't apply this code to a RenPy game because save/load process is controlled by RenPy in it's loadsave.py module. Is there a way to fix loading without patching RenPy code? Any monkeypatch ideas?

1 Answer

What I usually do when I move stuff around in Ren'Py is to just create an alias from the old name of the class to the new name. That's enough for pickle - it looks up the old name, and creates a class with the new name.

For example, if I had

class OldClass(object): pass 

and wanted to rename it to NewClass, I would have the code:

class NewClass(object): pass OldClass = NewClass 

This works across modules, too.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like