From 17cb40f46ab6eb9906abe96bd6b05e52c4108655 Mon Sep 17 00:00:00 2001 From: inportb Date: Sat, 1 Oct 2022 00:32:48 -0400 Subject: [PATCH] Count 0 maximum string length for empty RPC list parameters --- rpc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rpc.py b/rpc.py index 6985f0b..117b7be 100644 --- a/rpc.py +++ b/rpc.py @@ -45,9 +45,9 @@ def l_pack(value: Any, envelope: int=3, wrapped: bool=True, basictype=b'0', enco def l_pack_maxlen(value: Any, encoding: str='latin-1'): if isinstance(value, dict): - return max(max(l_pack_maxlen(k, encoding=encoding) for k in value.keys()), max(l_pack_maxlen(v, encoding=encoding) for v in value.values())) + return max(max(l_pack_maxlen(k, encoding=encoding) for k in value.keys()), max(l_pack_maxlen(v, encoding=encoding) for v in value.values())) if len(value) > 0 else 0 elif not isinstance(value, str) and hasattr(value, '__iter__'): - return max(len(str(max(0, len(value) - 1))), max(l_pack_maxlen(v, encoding=encoding) for v in value)) + return max(len(str(len(value))), max(l_pack_maxlen(v, encoding=encoding) for v in value)) if len(value) > 0 else 0 else: return len(str(value).encode(encoding))