BUG: ValueError: need more than 1 values to unpack
Closed this issue · 1 comments
xuancong84 commented
Sometimes, I get this error:
Traceback (most recent call last):
File "microdot_asyncio.py", line 331, in handle_request
File "microdot_asyncio.py", line 103, in create
File "microdot.py", line 350, in __init__
File "microdot.py", line 408, in _parse_urlencoded
ValueError: need more than 1 values to unpack
The reason is because in Line 407/408 of microdot.py
:
for k, v in [pair.split('=', 1) for pair in urlencoded.split('&') if pair]:
sometimes, pair
does not contain '=', so pair.split('=',1)
gives only one output, cannot unpack.
I suggest change to:
for k, v in [pair.split('=', 1) for pair in urlencoded.split('&') if '=' in pair]:
miguelgrinberg commented
Good catch. It's unusual, but yes, there shouldn't be a crash in this situation.