r/Python • • 1h ago

Tutorial A one-line rename in Python 3.15 broke loading of every old pickle

Python 3.15's new sentinel() comes back from a pickle as the same object, which the old object() idiom never did. The catch: it does this by saving its name. Rename MISSING to UNSET and every file saved earlier fails to load.

I wrote up why it happens and the one-line fix: https://www.tk1s.com/python/python-sentinel-rename-breaks-pickle

0 Upvotes

4 comments sorted by

16

u/really_not_unreal 1h ago

Me when the breaking changes cause breakages.

As per the documentation:

Serialization is a more primitive notion than persistence; although pickle reads and writes file objects, it does not handle the issue of naming persistent objects, nor the (even more complicated) issue of concurrent access to persistent objects

Pickle is a system for serialisation, and while it works for persistence to some extent, it is not ideal for this. The documentation warns about requiring access to the same data structures in order to unpickle them. In essence: you shouldn't be expecting things like this to work. You should instead use the right tool for the job: a database.

19

u/amarao_san 1h ago

Slop.

6

u/Mother_Day7350 1h ago

Might as well pickle the name at that point.

•

u/Individual-Flow9158 24m ago edited 17m ago

Yet another reason to be glad I've never gone anywhere near pickle with a barge pole.

Who on earth is still using pickle in 2026, FFS?

tk1s Programming and AI coding guides for vibe coders.

Oh.