From 50a66a2dc9a17c6fdd06d8eb602e2ddd721909e5 Mon Sep 17 00:00:00 2001 From: Rob McMullen Date: Tue, 5 Jun 2018 18:13:58 -0700 Subject: [PATCH] Fixed deserialization to handle the start_addr to origin renaming --- atrcopy/segments.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/atrcopy/segments.py b/atrcopy/segments.py index 3b524b5..fda0ff3 100644 --- a/atrcopy/segments.py +++ b/atrcopy/segments.py @@ -505,6 +505,7 @@ class DefaultSegment(object): self.can_resize = state.pop('can_resize', self.__class__.can_resize_default) self.restore_missing_serializable_defaults() self.__dict__.update(state) + self.restore_renamed_serializable_attributes() def restore_missing_serializable_defaults(self): """Hook for the future when extra serializable attributes are added to @@ -513,6 +514,17 @@ class DefaultSegment(object): """ pass + def restore_renamed_serializable_attributes(self): + """Hook for the future if attributes have been renamed. The old + attribute names will have been restored in the __dict__.update in + __setstate__, so this routine should move attribute values to their new + names. + """ + if hasattr(self, 'start_addr'): + self.origin = self.start_addr + print(f"moving start_addr to origin: {self.start_addr}") + delattr(self, 'start_addr') + def reconstruct_raw(self, rawdata): """Reconstruct the pointers to the parent data arrays