You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
lazy imports filter sees the same thing for from x import y and from .x import y #148110
The lazy imports filter gets the unresolved module name for relative imports, so lazy from target import VALUE and lazy from .target import VALUE look identical to the callback even though they resolve to different modules. In this repro both filter calls print ('pkg.runner', 'target', ('VALUE',)), so the filter cannot tell the absolute and relative cases apart.
$ tmpdir=$(mktemp -d)
$ mkdir -p "$tmpdir/pkg"
$ cat >"$tmpdir/target.py"<<'PY'VALUE = 'absolute'PY
$ cat >"$tmpdir/pkg/__init__.py"<<'PY'PY
$ cat >"$tmpdir/pkg/target.py"<<'PY'VALUE = 'relative'PY
$ cat >"$tmpdir/pkg/runner.py"<<'PY'import sysdef my_filter(importer, name, fromlist): print((importer, name, fromlist)) return Truesys.set_lazy_imports_filter(my_filter)lazy from target import VALUE as absolute_valuelazy from .target import VALUE as relative_valuePY
$ PYTHONPATH="$tmpdir" ./python -c 'import pkg.runner'('pkg.runner', 'target', ('VALUE',))('pkg.runner', 'target', ('VALUE',))
changed the title [-]sys.set_lazy_imports_filter cannot distinguish \ from \[/-][+]lazy imports filter sees the same thing for `from x import y` and `from .x import y`[/+]on Apr 4, 2026
Activity
[-]sys.set_lazy_imports_filter cannot distinguish \ from \[/-][+]lazy imports filter sees the same thing for `from x import y` and `from .x import y`[/+]pythongh-148110: Resolve lazy import filter names for relative imports
pablogsal commentedon Apr 4, 2026
CC @1st1
picnixz commentedon Apr 4, 2026
sys.set_lazy_imports_filterloses information when doing relative imports #148026 as a duplicate of this issuegh-148110: Resolve lazy import filter names for relative imports (#14…
sys.set_lazy_imports_filter(...): Relative imports indistinguishable from absolute imports #145864 as a duplicate of this issuepythongh-148110: Resolve lazy import filter names for relative imports (
pythongh-148110: Resolve lazy import filter names for relative imports (