diff --git a/aiochclient/_types.pyx b/aiochclient/_types.pyx index a1123be..9c04e61 100644 --- a/aiochclient/_types.pyx +++ b/aiochclient/_types.pyx @@ -552,7 +552,10 @@ cdef class MapType: self.value_type = what_py_type(tps[comma_index + 1:], container=True) cdef dict _convert(self, str string): - key, value = string[1:-1].split(':', 1) + splits = string[1:-1].split(':', 1) + if len(splits) < 2: + return {} + key, value = splits return { self.key_type.p_type(decode(key.encode())): self.value_type.p_type(decode(value.encode())) } diff --git a/aiochclient/types.py b/aiochclient/types.py index efa3fab..2080afb 100644 --- a/aiochclient/types.py +++ b/aiochclient/types.py @@ -322,7 +322,10 @@ def __init__(self, name: str, **kwargs): self.value_type = what_py_type(tps[comma_index + 1 :], container=True) def p_type(self, string: str) -> dict: - key, value = string[1:-1].split(':', 1) + splits = string[1:-1].split(':', 1) + if len(splits) < 2: + return {} + key, value = splits return { self.key_type.p_type(self.decode(key.encode())): self.value_type.p_type( self.decode(value.encode())