From 503a77925e68e8243a89693050100a5f1dc16033 Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Fri, 17 May 2019 00:44:10 -0700 Subject: [PATCH] Move away from __dict__ style save/load Incompatible with previous versions, but necessary given the move to __slots__. Also use pickle.HIGHEST_PROTOCOL --- masque/pattern.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/masque/pattern.py b/masque/pattern.py index e47be49..f120c52 100644 --- a/masque/pattern.py +++ b/masque/pattern.py @@ -511,10 +511,8 @@ class Pattern: :return: Loaded Pattern """ with open(filename, 'rb') as f: - tmp_dict = pickle.load(f) + pattern = pickle.load(f) - pattern = Pattern() - pattern.__dict__.update(tmp_dict) return pattern def save(self, filename: str) -> 'Pattern': @@ -525,7 +523,7 @@ class Pattern: :return: self """ with open(filename, 'wb') as f: - pickle.dump(self.__dict__, f, protocol=2) + pickle.dump(self, f, protocol=pickle.HIGHEST_PROTOCOL) return self def visualize(self,