Files
graphify/tests
safishamsiandClaude Opus 4.8 289aa41284 fix(python): stop a stdlib-named loose module from capturing a bare import (#4261)
A non-package directory with a file named like a stdlib module (e.g.
`scripts/logging.py`) wrongly captured a bare `import logging` from a
sibling, binding the import — and member calls like `logging.getLogger()` —
to the local file instead of the stdlib module.

The false binding arose at three independent layers, all now guarded by a
vendored, deterministic `_PYTHON_STDLIB_MODULE_NAMES` frozenset (union of
3.10 and 3.13 `sys.stdlib_module_names`, NOT the host's live set):

- `_resolve_python_module_path`: an absolute import whose top-level name is
  a stdlib module no longer resolves to a loose same-named `.py` file or
  namespace dir. A deliberate package shadow (`logging/__init__.py`) still
  resolves — only loose modules/namespaces are refused.
- `_repoint_python_sibling_imports`: stdlib-named loose siblings are no
  longer indexed as repoint targets.
- build.py #1504 pre-migration stem-alias index: a stdlib-named Python file
  no longer claims the collapsed bare-stem alias ("logging"), which would
  otherwise re-capture the external edge. The directory-scoped alias
  ("scripts_logging") is still registered, so genuine stale-id references to
  the file keep healing.

Adds a stdlib-shadow regression plus a non-stdlib positive control.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-10 01:24:41 +01:00
..