[SOLVED] urllib.parse: MemoryError: memory allocation failed, allocating 560 bytes
-
Getting this error when I import uPython's urllib.
>>> import urllib.parse Traceback (most recent call last): File "<stdin>", line 1, in <module> MemoryError: memory allocation failed, allocating 560 bytes >>>Best I can tell it's generating the error on line 475 where _hextobyte is created.
Does it work for you? I have a WiPy 2.0, using the latest firmware.
-
@BetterAuto
You have not enough memory
Did you tested this after "fresh" reboot without any other your code?
I do not like when libs import whole units
e.g.import mathcan eat near to whole memory
but better is to do e.g.
from math import sin,cos,piYou can try to modify imports used in urllib - and you will see if it solve your problem
-
@livius Yes this is a fresh boot with nothing in boot.py or main.py, no extra code is running. Even importing just the requested module still blows up memory.
>>> import gc;gc.mem_free() 65056 >>> from urllib.parse import unquote Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/flash/lib/urllib/parse.py", line 475, in <module> File "/flash/lib/urllib/parse.py", line 475, in <dictcomp> MemoryError: memory allocation failed, allocating 2344 bytes >>>All is good though. I found a module written for WiPy 1.0 that has worked around the memory issues. The problem still needs to be fixed in uPython mainline libraries, but this workaround works for me.
>>> from urllib import unquote >>> unquote('abc%20def') 'abc def' >>>
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login