From 6cf99694f40149c619310f5c4e371bec005e5a87 Mon Sep 17 00:00:00 2001 From: Douglas RAILLARD Date: Thu, 13 Jun 2019 14:21:56 +0100 Subject: [PATCH] lisa.utils: Fix Serializable.__copy__ Since object.__copy__ does not work, fall back on some __dict__ copy behavior if super().__copy__ does not exist. --- lisa/utils.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lisa/utils.py b/lisa/utils.py index c97f8449e..067768f93 100644 --- a/lisa/utils.py +++ b/lisa/utils.py @@ -468,10 +468,17 @@ class Serializable(Loggable): self.__dict__ = dct def __copy__(self): - """Make sure that copying the class still works as usual, without - dropping some attributes by defining __copy__ - """ - return super().__copy__() + """ + Make sure that copying the class still works as usual, without + dropping some attributes by defining __copy__ + """ + try: + return super().__copy__() + except AttributeError: + cls = self.__class__ + new = cls.__new__(cls) + new.__dict__.update(self.__dict__) + return new Serializable._init_yaml() -- GitLab