mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-07 15:34:52 +00:00
Fix encoder breaking with bytes
This commit is contained in:
parent
52b9319734
commit
d31a696f32
1 changed files with 5 additions and 1 deletions
|
|
@ -43,5 +43,9 @@ def remove_none(obj):
|
||||||
|
|
||||||
class Encoder(JSONEncoder):
|
class Encoder(JSONEncoder):
|
||||||
def default(self, o: PyrogramType):
|
def default(self, o: PyrogramType):
|
||||||
|
try:
|
||||||
content = {i: getattr(o, i) for i in filter(lambda x: not x.startswith("_"), o.__dict__)}
|
content = {i: getattr(o, i) for i in filter(lambda x: not x.startswith("_"), o.__dict__)}
|
||||||
|
except AttributeError:
|
||||||
|
return repr(o)
|
||||||
|
|
||||||
return remove_none(OrderedDict([("_", "pyrogram:" + o.__class__.__name__)] + [i for i in content.items()]))
|
return remove_none(OrderedDict([("_", "pyrogram:" + o.__class__.__name__)] + [i for i in content.items()]))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue