← index #4923PR #399
Off-topic · high · value 1.033
QUERY · ISSUE

BUG: sys.modules['sys'] not pointing __import__('sys')

openby pmp-popened 2019-07-16updated 2019-07-16

Probably the same reason as :
https://github.com/micropython/micropython/issues/4427

CANDIDATE · PULL REQUEST

ffilib:fix Traceback in Unix port due to missing 'maxsize'

openby pvinciopened 2020-09-30updated 2020-10-01

from machine import I2C
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/root/.micropython/lib/machine/init.py", line 2, in <module>
File "/root/.micropython/lib/machine/timer.py", line 1, in <module>
File "/root/.micropython/lib/ffilib.py", line 43, in <module>
AttributeError: 'module' object has no attribute 'maxsize'

1 comment
jimmo · 2020-10-01

I think the issue here is that micropython-lib's sys module needs to be updated since https://github.com/micropython/micropython/pull/6164 renamed the builtin from sys to usys.

So what used to happen is that import sys got the builtin, whereas since https://github.com/micropython/micropython/pull/6164 it now gets micropython-lib's empty sys.py

The fix is that sys.py should "inherit" from usys by having from usys import * at the start. This is what's done for other modules. Are you able to test that and see if it resolves the issue?

The other fix is that micropython-lib shouldn't contain these empty placeholder modules.... see #376 for some thoughts on that.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied