Access io.IOBase in Unix build?

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
User avatar
pythoncoder
Posts: 3053
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Access io.IOBase in Unix build?

Post by pythoncoder » Fri Nov 09, 2018 11:06 am

The current Unix build errors if you issue

Code: Select all

import io
Is there a reason why this module is not included in the build?

I attempted to remedy this by including the line

Code: Select all

#define MICROPY_PY_IO               (1)
in unix/mpconfigport.h (culled from the equivalent STM file).

A modio.o file is now created but I still can't import the module. I'm not too well-up on the build system - is there another step I need to take for the module to be linked in?
Peter Hinch

jickster
Posts: 532
Joined: Thu Sep 07, 2017 8:57 pm

Re: Access io.IOBase in Unix build?

Post by jickster » Fri Nov 09, 2018 11:27 pm

I text searched all of 1.9.4 and I don't see that it's available in Unix
Search "MP_QSTR_io" (2 hits in 2 files)
C:\work\micropython\micropython_from_github\micropython-1.9.4\ports\esp32\mpconfigport.h (1 hit)
Line 194: { MP_OBJ_NEW_QSTR(MP_QSTR_io), (mp_obj_t)&mp_module_io }, \
C:\work\micropython\micropython_from_github\micropython-1.9.4\ports\stm32\mpconfigport.h (1 hit)
Line 227: { MP_ROM_QSTR(MP_QSTR_io), MP_ROM_PTR(&mp_module_io) }, \
You'll have to make more modifications to make mp_module_io available in Unix.

User avatar
pythoncoder
Posts: 3053
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Access io.IOBase in Unix build?

Post by pythoncoder » Sat Nov 10, 2018 7:46 am

Thanks for that - it provided the clue I was missing. It now imports correctly. Whether or not it actually works is moot until I debug my code ;)

For the record I also needed to append the final line below

Code: Select all

#define MICROPY_PORT_BUILTIN_MODULES \
    MICROPY_PY_FFI_DEF \
(lines omitted)
    { MP_ROM_QSTR(MP_QSTR_io), MP_ROM_PTR(&mp_module_io) }, \
Peter Hinch

User avatar
pythoncoder
Posts: 3053
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Access io.IOBase in Unix build?

Post by pythoncoder » Sat Nov 10, 2018 10:43 am

I spoke too soon. I can import the module but it does not work. There is evidently something subtle here. I'll raise an issue.
Peter Hinch

Post Reply