diff options
author | Jim Mussared <jim.mussared@gmail.com> | 2023-05-10 13:02:09 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2023-06-01 16:03:21 +1000 |
commit | 42f3f66431bb3131f5ee78f3e121491e9d0fb91d (patch) | |
tree | d645e0abf05402ff9123915dc0d840a8eb274da0 /examples/usercmodule/cppexample/micropython.cmake | |
parent | 69dd013919461272b3669a516ef98d60accd3165 (diff) | |
download | micropython-42f3f66431bb3131f5ee78f3e121491e9d0fb91d.tar.gz micropython-42f3f66431bb3131f5ee78f3e121491e9d0fb91d.zip |
py/builtinimport: Handle empty sys.path correctly.
If sys.path is enabled, but empty, this will now no longer search the
filesystem. Previously an empty sys.path was equivalent to having
`sys.path=[""]`. This is a breaking change, but this behavior now matches
CPython.
This also provides an alternative mechanism to the u-prefix to force an
import of a builtin module:
```
import sys
_path = sys.path[:]
sys.path.clear()
import foo # Forces the built-in foo.
sys.path.extend(_path)
del _path
```
Code size diff is -32 bytes on PYBV11.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Diffstat (limited to 'examples/usercmodule/cppexample/micropython.cmake')
0 files changed, 0 insertions, 0 deletions