class documentation

Importer that restricts modules.

Method __init__ Create importer.
Method applied Context manager to apply this restrictive import.
Instance Variable import_func Undocumented
Instance Variable modules_checked_for_restrictions Undocumented
Instance Variable new_modules Undocumented
Instance Variable restricted_builtins Undocumented
Instance Variable restriction_context Undocumented
Instance Variable restrictions Undocumented
Method _assert_valid_module Undocumented
Method _builtins_restricted Undocumented
Method _builtins_unrestricted Undocumented
Method _import Undocumented
Method _maybe_passthrough_module Undocumented
Method _maybe_restrict_module Implements _Environment.maybe_restrict_module.
Method _traced_import Undocumented
Method _unapplied Undocumented
def __init__(self, restrictions: SandboxRestrictions, restriction_context: RestrictionContext): (source)

Create importer.

Context manager to apply this restrictive import.

Warning

This currently alters global sys.modules and builtins.__import__ while it is running and therefore should be locked against other code running at the same time.

import_func = (source)

Undocumented

modules_checked_for_restrictions: Set[str] = (source)

Undocumented

Undocumented

Undocumented

restriction_context = (source)

Undocumented

restrictions = (source)

Undocumented

def _assert_valid_module(self, name: str): (source)

Undocumented

@contextmanager
def _builtins_restricted(self) -> Iterator[None]: (source)

Undocumented

@contextmanager
def _builtins_unrestricted(self) -> Iterator[None]: (source)

Undocumented

def _import(self, name: str, globals: Optional[Mapping[str, object]] = None, locals: Optional[Mapping[str, object]] = None, fromlist: Sequence[str] = (), level: int = 0) -> types.ModuleType: (source)

Undocumented

def _maybe_passthrough_module(self, name: str) -> Optional[types.ModuleType]: (source)

Undocumented

def _maybe_restrict_module(self, mod: types.ModuleType) -> Optional[types.ModuleType]: (source)

Implements _Environment.maybe_restrict_module.

def _traced_import(self, name: str, globals: Optional[Mapping[str, object]] = None, locals: Optional[Mapping[str, object]] = None, fromlist: Sequence[str] = (), level: int = 0) -> types.ModuleType: (source)

Undocumented

@contextmanager
def _unapplied(self) -> Iterator[None]: (source)

Undocumented