From bf9db70bee5c2cbcfe20a7676f9db9a64b22fb17 Mon Sep 17 00:00:00 2001 From: Goffi Date: Mon, 12 Jun 2023 14:57:27 +0200 Subject: [PATCH] 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. --- libervia/backend/memory/sqla_mapping.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libervia/backend/memory/sqla_mapping.py b/libervia/backend/memory/sqla_mapping.py index 377e4948..4735cafe 100644 --- a/libervia/backend/memory/sqla_mapping.py +++ b/libervia/backend/memory/sqla_mapping.py @@ -102,7 +102,15 @@ class LegacyPickle(TypeDecorator): 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):