urequests "need more than 2 values to unpack"
-
I thought I should post this on the MicroPython forum (as I am using urequests from the micropython-lib), but I was directed to post here. So I guess I'll do that.
Here is my problem:
Hi!
I am trying to send a request to my OTA update server using urequests.
However, I am getting an exception that I found somewhat strange:Traceback (most recent call last): File "<stdin>", line 1, in <module> File "ota.py", line 50, in <module> File "ota.py", line 50, in <module> File "ota.py", line 47, in <module> File "/flash/lib/urequests.py", line 114, in get File "/flash/lib/urequests.py", line 39, in request ValueError: need more than 2 values to unpack
The request code I am using is:
urequests.get(url, headers={"User-Agent": "xxx (not actual value)"}, data={"deviceid": "xxx (not actual value)"})
Can someone figure this out for me? If I remove one of these, I still get the exception, but with "need more than 1 value to unpack".
The board I am using is a PyCom WiPy 3.0.
-
@techykermit Things like these happen all of us the time. But still, the python code could have an error handling for it, like the two lines before.
-
@robert-hh This is another one of those silly mistakes you make while coding... I loaded the URL from a data storage file but forgot to add https:// in the beginning. It works fine now!
-
@jcaron I do not agree, especially since I verified that: to my surprise the error message matches. if you use a string like:
url = http:/x.y
line 39 will produce exactly this error message. You can try yourself in REPL:proto, dummy, host = "x:/y.z".split("/", 2)
I looked first for something like struct.unpack() as the source of the error. And so I learned that split may cause that message too.
-
@robert-hh Line numbers don’t match. Line 114 is not in
get
, so it’s unlikely line 39 matches (and the error message definitely doesn’t match).@techykermit can you double check what version of urequests you are using?
-
@techykermit So line 39 is:
proto, dummy, host = url.split("/", 2)
What is the content of url? It should be of the form:
'proto://host' e.g.
'https://forum.pycom.io'
-
@robert-hh This is the urequests I am using (from micropython-lib):
https://github.com/micropython/micropython-lib/blob/master/urequests/urequests.py
-
@techykermit Can you tell, which of the various urequest variants you are trying?