Skip to content
Snippets Groups Projects
Commit 4147f41b authored by Piotr Maślanka's avatar Piotr Maślanka
Browse files

strange bug: happens only in Python 3.11

parent 78ddf796
No related branches found
No related tags found
No related merge requests found
...@@ -43,15 +43,14 @@ class JSONEncoder(json.JSONEncoder): ...@@ -43,15 +43,14 @@ class JSONEncoder(json.JSONEncoder):
try: try:
v = super().default(o) v = super().default(o)
except TypeError: except TypeError:
dct = {} v = {}
try: try:
for k, v in o.__dict__.items(): for k, val in o.__dict__.items():
dct[k] = self.default(v) v[k] = self.default(val)
v = dct
except AttributeError: # o has no attribute '__dict__', try with slots except AttributeError: # o has no attribute '__dict__', try with slots
try: try:
for slot in o.__slots__: 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? except AttributeError: # it doesn't have __slots__ either?
v = '<an instance of %s>' % (o.__class__.__name__,) v = '<an instance of %s>' % (o.__class__.__name__,)
return v return v
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment