From d292d9d19ac595238fa13907a8b05308c135a59d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jarkko=20P=C3=B6yry?= Date: Sat, 7 Oct 2023 15:16:03 +0300 Subject: [PATCH] Apply review feedback. --- miio/protocol.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/miio/protocol.py b/miio/protocol.py index bddb40b20..0a7a0158d 100644 --- a/miio/protocol.py +++ b/miio/protocol.py @@ -161,11 +161,9 @@ def _encode(self, obj, context, path): def _decode(self, obj, context, path) -> Union[Dict, bytes]: """Decrypts the payload using the token stored in the context.""" - # if there is no payload, decode to 0 bytes. Missing payload is expected for discovery messages. - # note that we don't have "token" in the context for discovery replies so we couldn't decode it - # anyway. - if obj == b"": - return b"" + # Missing payload is expected for discovery messages. + if not obj: + return obj try: decrypted = Utils.decrypt(obj, context["_"]["token"]) decrypted = decrypted.rstrip(b"\x00")