def _access_value(self) -> T: current_frame = self._frame_ident(_getframe().f_back.f_back.f_back) import traceback traceback.print_stack() if current_frame == self._frame: return self._value else: raise SecurityError( f'Protected {self._tag_type} value from ' f'field {self._field_name} accessed outside origin frame.')
def __format__(self, format_spec: str) -> str: raise SecurityError(f"Attempt to use {self._name} data as a string")
def __str__(self) -> str: raise SecurityError(f"Attempt to use {self._name} data as a string")
def __init__(self, value: T, *, field: str = None): if isinstance(value, Tag): raise SecurityError("Cannot wrap: value is already tagged") self._value = value self.field = field