From 8bb20730fca03ad8c5565ee3f73676816870051e Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Wed, 17 Feb 2021 09:33:33 -0800 Subject: [PATCH] Fixes bug in serializing dataclasses in place --- bookwyrm/activitypub/base_activity.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/bookwyrm/activitypub/base_activity.py b/bookwyrm/activitypub/base_activity.py index 10cbf3a0..8b538f0b 100644 --- a/bookwyrm/activitypub/base_activity.py +++ b/bookwyrm/activitypub/base_activity.py @@ -162,15 +162,14 @@ class ActivityObject: def serialize(self): ''' convert to dictionary with context attr ''' - data = self.__dict__ + data = self.__dict__.copy() # recursively serialize for (k, v) in data.items(): try: - is_subclass = issubclass(type(v), ActivityObject) + if issubclass(type(v), ActivityObject): + data[k] = v.serialize() except TypeError: - is_subclass = False - if is_subclass: - data[k] = v.serialize() + pass data = {k:v for (k, v) in data.items() if v is not None} data['@context'] = 'https://www.w3.org/ns/activitystreams' return data