From 0e693c724bb75e85bda4fcb594b8169e2e187fce Mon Sep 17 00:00:00 2001 From: Richard Neumann Date: Sun, 21 Aug 2022 15:19:38 +0200 Subject: [PATCH] Add some sanity checks to Packet.__add__() --- rcon/source/proto.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/rcon/source/proto.py b/rcon/source/proto.py index 4d88283..5201db5 100644 --- a/rcon/source/proto.py +++ b/rcon/source/proto.py @@ -91,6 +91,15 @@ class Packet(NamedTuple): if other is None: return self + if other.id != self.id: + raise ValueError('Can only add packages with same id.') + + if other.type != self.type: + raise ValueError('Can only add packages of same type.') + + if other.terminator != self.terminator: + raise ValueError('Can only add packages with same terminator.') + return Packet( self.id, self.type,