Mercurial > libervia-backend
changeset 4095:684ba556a617
core (memory/sqla_mapping): fix legacy pickled values:
folloing packages refactoring, legacy pickled values could not be unpickled (due to use of
old classes). This temporary workaround fix it, but the right thing to do will be to move
from pickle to JSON at some point.
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 12 Jun 2023 14:57:27 +0200 |
parents | c3b68fdc2de7 |
children | 087902fbb77a |
files | libervia/backend/memory/sqla_mapping.py |
diffstat | 1 files changed, 9 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/libervia/backend/memory/sqla_mapping.py Mon Jun 12 14:50:43 2023 +0200 +++ b/libervia/backend/memory/sqla_mapping.py Mon Jun 12 14:57:27 2023 +0200 @@ -102,7 +102,15 @@ except AttributeError: pass # "utf-8" encoding is needed to handle Python 2 pickled data - return pickle.loads(value, encoding="utf-8") + try: + return pickle.loads(value, encoding="utf-8") + except ModuleNotFoundError: + # FIXME: workaround due to package renaming, need to move all pickle code to + # JSON + return pickle.loads( + value.replace(b"sat.plugins", b"libervia.backend.plugins"), + encoding="utf-8" + ) class Json(TypeDecorator):