from X import * does not bind call-table members
from random import *
seed(1) # before: undefined variable (seed)
Fix (compiler/pyparser.inc)
PyStdStarRecord(root)remembers each star-imported root per importing unit. Both from-import arms call it: the consumed-only one (sys, os, os.path) and the unit one (random has a unit and table members).PyStdAliasLookupfalls back to the star roots after the explicit aliases. A bare name binds if a star root of this unitPyStdProvidesMembers it. That is the same membership testfrom sys import argvuses, so the explicit and star forms cannot disagree, and nothing enumerates the table. The shadowing test is the explicit form's: a def bound here or a module variable wins. Names starting with_are not bound. The call-table roots define no__all__, so CPython's rule is public names.- Its early exit tested only the explicit table's count, so the star table was never consulted until that was fixed.
Against CPython
For every root in PyStdlibCallProc, CPython's from <root> import *
binds every member the table maps, except os.startfile (Windows-only;
here it binds but CPython on Linux has no such name).
Shim modules
machine and time are Pascal units under lib/rtl/platform/esp and
lib/rtl, so a star import already reached their names through flat unit
scope. A Pascal unit has no __all__. A .py shim goes through
PyStarImportRecord, which honours __all__.
Rows
- test/test_nilpy_from_import_star_of_a_compiler_provided_module.npy, with
test/starmod_randint_own.py and .expected from CPython. It covers
random, sys, os and os.path members, a later def and a later
assignment winning, and an imported module keeping its own
randint. x64 (fromstarct26); red before the fix. - test/esp_from_machine_import_star.npy: an ESP32-C3 build-only row
(riscv32, --platform=esp). It also builds on the compiler before this
fix, so it guards the idiom rather than this change. Under QEMU
(tools/esp_run.sh --chip esp32c3, ESP_RUN_PROJECT=nilpy-hw-c3) it prints
0 True, the same as the qualified spelling.