示例#1
0
 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.')
示例#2
0
 def __format__(self, format_spec: str) -> str:
     raise SecurityError(f"Attempt to use {self._name} data as a string")
示例#3
0
 def __str__(self) -> str:
     raise SecurityError(f"Attempt to use {self._name} data as a string")
示例#4
0
 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