diff --git a/satella/json.py b/satella/json.py index 1578b291fd07b4a1a33c2aac6fa4841046f75515..073412df2b619a4fc6c6fe7f07935d9f438a5009 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