getenv() error with UNIX micropython

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
Nico
Posts: 10
Joined: Wed Oct 28, 2015 6:56 am

getenv() error with UNIX micropython

Post by Nico » Sat Nov 14, 2015 3:06 pm

Hi,

I would like to make HBMQTT work with micropython. I've cloned micropython repo (head revision) and built UNIX successfully.
Before being able to run, I need to install some dependencies like logging. Therefore, I run the following command :

Code: Select all

./micropython -v -m upip install logging
Unfortunatelly, it gives the following error:

Code: Select all

./micropython -v -m upip install logging
Traceback (most recent call last):
  File "", line 291, in <module>
  File "", line 252, in main
TypeError: function takes 1 positional arguments but 2 were given
I guess it comes from upip 0.6 which is frozen in micropython. Looking at upip.py source code shows that line 252 is :

Code: Select all

 install_path = os.getenv("MICROPYPATH", DEFAULT_MICROPYPATH)
 
Recents modification make on import on this module could cause this error.... So I decided to try fo fix this. I:
- cloned micropython-lib
- changed install_path = os.getenv("MICROPYPATH", DEFAULT_MICROPYPATH) to install_path = os.getenv("MICROPYPATH") or DEFAULT_MICROPYPATH
- run python setup.py sdist (with CPython3)
- copied micropython-upip-0.6.tar.gz to micropython/tools
- make clean all on unix/
then run again upip gives now :

Code: Select all

./micropython -v -m upip install logging
Segmentation fault: 11
Can you tell if I'm right with the origin of this error (wrong getenv() being called) ? If so, how can I go further with this segmentation fault ?

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: getenv() error with UNIX micropython

Post by pfalcon » Sat Nov 14, 2015 3:57 pm

Thanks, both issues are indeed artifacts of considerable recent refactoring, and now should be fixed in master. It's better to report bugs to https://github.com/micropython/micropython/issues though.
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

Nico
Posts: 10
Joined: Wed Oct 28, 2015 6:56 am

Re: getenv() error with UNIX micropython

Post by Nico » Sat Nov 14, 2015 6:16 pm

Thanks for your reply. I could have created a pull request but I missed the change in unix/modos.c, which I guess was causing the seg fault.

Post Reply