interpreter: never expose implementation details of the modules package

When a user writes `import'foo')`, Meson checks the
`mesonbuild/modules/` directory for a package called `foo.py`, and
attempts to import it. We don't want to expose any implementation detail
packages like `_qt.py`, so if someone write `import('_qt')`, we should
immediately give a "doesn't exist" error.
pull/13066/head
Dylan Baker 11 months ago
parent d617dc6869
commit d6a0b7a6ec
  1. 4
      mesonbuild/interpreter/interpreter.py

@ -608,6 +608,10 @@ class Interpreter(InterpreterBase, HoldableObject):
if disabled:
return NotFoundExtensionModule(modname)
# Always report implementation detail modules don't exist
if modname.startswith('_'):
raise InvalidArguments(f'Module "{modname}" does not exist')
expect_unstable = False
# Some tests use "unstable_" instead of "unstable-", and that happens to work because
# of implementation details

Loading…
Cancel
Save