fix: when deserializing specialize for received proto

This commit is contained in:
əlemi 2024-01-17 02:09:51 +01:00
parent f5ae50bfd7
commit 0e4d59ec51
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -56,8 +56,9 @@ class Packet:
fallback_proto -= 1
for k, t in cls._definitions[fallback_proto]:
setattr(ctx, k, t.read(buffer, ctx=ctx))
return cls(**ctx.serialize())
# return cls(proto, **{ name : t.read(buffer) for (name, t) in cls._definitions[proto] })
packet = cls(**ctx.serialize())
packet.for_proto(fallback_proto)
return packet
def serialize(self, proto:int) -> io.BytesIO:
self.for_proto(proto) # this sets both id and definitions but mypy doesn't know...