diff --git a/CHANGELOG.md b/CHANGELOG.md index e9110c8f284ee709df4a8b56f63b3e7e9559822b..6efb9ace73056e38afc54013a04b9d5a57906d3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ * added safe_listdir * fixed a bug occurring in Python 3.10 with whereis * DirectorySource will raise an exception if directory does not exist and on_fail is set to RAISE +* JSONEncoder will behave correctly on weird classes (no __slots and no __dict__) Build system ============ diff --git a/satella/__init__.py b/satella/__init__.py index b8a2e669b691ad10da88afcdd72ca15a361fbfd7..2449a86b68a01ae05646eee7a7fe3c4a66a62970 100644 --- a/satella/__init__.py +++ b/satella/__init__.py @@ -1 +1 @@ -__version__ = '2.25.0a3' +__version__ = '2.25.0a4' diff --git a/satella/json.py b/satella/json.py index 9a74d00065d1efc4f5b1a01e58933a421456334c..1975a4f4f852f4136d156ac2d96d3dc1080ac6dd 100644 --- a/satella/json.py +++ b/satella/json.py @@ -46,13 +46,13 @@ class JSONEncoder(json.JSONEncoder): try: for k, v in o.__dict__.items(): dct[k] = self.default(v) + v = dct except AttributeError: # o has no attribute '__dict__', try with slots try: for slot in o.__slots__: dct[slot] = self.default(getattr(o, slot)) except AttributeError: # it doesn't have __slots__ either? v = '<an instance of %s>' % (o.__class__.__name__,) - v = dct return v