Count 0 maximum string length for empty RPC list parameters
This commit is contained in:
parent
26b4a116ba
commit
17cb40f46a
4
rpc.py
4
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'):
|
def l_pack_maxlen(value: Any, encoding: str='latin-1'):
|
||||||
if isinstance(value, dict):
|
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__'):
|
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:
|
else:
|
||||||
return len(str(value).encode(encoding))
|
return len(str(value).encode(encoding))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user