Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: need more than 1 value to unpack error when map is totally empty #116

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion aiochclient/_types.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
}
Expand Down
5 changes: 4 additions & 1 deletion aiochclient/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down