From 0c8b19b5599e07c904651cfc3a4f2f3e67842f30 Mon Sep 17 00:00:00 2001 From: Marko Toplak Date: Fri, 26 Jun 2020 13:21:05 +0200 Subject: [PATCH] settings: save with pickle protocol 4 Before the settings were saved with the highest protocol, which could make workflows saved on Python 3.8 incompatible with older Python. We still support Python 3.6. --- orangewidget/settings.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/orangewidget/settings.py b/orangewidget/settings.py index 785f66c3e..071cfd1f5 100644 --- a/orangewidget/settings.py +++ b/orangewidget/settings.py @@ -54,6 +54,9 @@ VERSION_KEY = "__version__" +# protocol v4 is supported since Python 3.4, protocol v5 since Python 3.8 +PICKLE_PROTOCOL = 4 + __WIDGET_SETTINGS_DIR = None # type: Optional[Tuple[str, str]] @@ -541,7 +544,7 @@ def write_defaults_file(self, settings_file): """ defaults = dict(self.defaults) defaults[VERSION_KEY] = self.widget_class.settings_version - pickle.dump(defaults, settings_file, -1) + pickle.dump(defaults, settings_file, protocol=PICKLE_PROTOCOL) def _get_settings_filename(self): """Return the name of the file with default settings for the widget""" @@ -765,7 +768,7 @@ def add_version(context): return context pickle.dump([add_version(context) for context in self.global_contexts], - settings_file, -1) + settings_file, protocol=PICKLE_PROTOCOL) def pack_data(self, widget): """Call the inherited method, then add local contexts to the dict."""