fix: when deserializing specialize for received proto
This commit is contained in:
parent
f5ae50bfd7
commit
0e4d59ec51
1 changed files with 3 additions and 2 deletions
|
@ -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...
|
||||
|
|
Loading…
Reference in a new issue