From 4147f41b55aa7245a5f03fc5f3157e5b1eef10dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Ma=C5=9Blanka?= <piotr.maslanka@henrietta.com.pl> Date: Thu, 7 Mar 2024 11:01:17 +0100 Subject: [PATCH] strange bug: happens only in Python 3.11 --- satella/json.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/satella/json.py b/satella/json.py index 1578b291..073412df 100644 --- a/satella/json.py +++ b/satella/json.py @@ -43,15 +43,14 @@ class JSONEncoder(json.JSONEncoder): try: v = super().default(o) except TypeError: - dct = {} + v = {} try: - for k, v in o.__dict__.items(): - dct[k] = self.default(v) - v = dct + for k, val in o.__dict__.items(): + v[k] = self.default(val) except AttributeError: # o has no attribute '__dict__', try with slots try: for slot in o.__slots__: - dct[slot] = self.default(getattr(o, slot)) + v[slot] = self.default(getattr(o, slot)) except AttributeError: # it doesn't have __slots__ either? v = '<an instance of %s>' % (o.__class__.__name__,) return v -- GitLab