class_docstr: The sandboxed environment.  It works like the regular environment but
  tells the compiler to generate sandboxed code.  Additionally subclasses of
  this environment may override the methods that tell the runtime what
  attributes or functions are safe to access.
  
  If the template tries to access insecure code a :exc:`SecurityError` is
  raised.  However also other exceptions may occur during the rendering so
  the caller has to ensure that all exceptions are caught.
class_docstr_tok: ["The","sandboxed","environment",".","It","works","like","the","regular","environment","but","tells","the","compiler","to","generate","sandboxed","code",".","Additionally","subclasses","of","this","environment","may","override","the","methods","that","tell","the","runtime","what","attributes","or","functions","are","safe","to","access",".","If","the","template","tries","to","access","insecure","code","a",":","exc",":","`","SecurityError","`","is","raised",".","However","also","other","exceptions","may","occur","during","the","rendering","so","the","caller","has","to","ensure","that","all","exceptions","are","caught","."]
docstr: If a format call is detected, then this is routed through this
  method so that our safety sandbox can be used for it.
docstr_tok: ["If","a","format","call","is","detected",",","then","this","is","routed","through","this","method","so","that","our","safety","sandbox","can","be","used","for","it","."]
code: def format_string(
      self,
      s: str,
      args: t.Tuple[t.Any, ...],
      kwargs: t.Dict[str, t.Any],
      format_func: t.Optional[t.Callable] = None,
  ) -> str:
      """If a format call is detected, then this is routed through this
      method so that our safety sandbox can be used for it.
      """
      formatter: SandboxedFormatter
      if isinstance(s, Markup):
          formatter = SandboxedEscapeFormatter(self, escape=s.escape)
      else:
          formatter = SandboxedFormatter(self)
  
      if (
          format_func is not None
          and format_func.__name__ == "format_map"
      ):
          if len(args) != 1 or kwargs:
              raise TypeError(
                  "format_map() takes exactly one argument"
                  f" {len(args) + (kwargs is not None)} given"
              )
  
          kwargs = args[0]
          args = ()
  
      rv = formatter.vformat(s, args, kwargs)
      return type(s)(rv)
  
imports: import operator
  import types
  import typing
  from _string import formatter_field_name_split
  from collections import abc
  from collections import deque
  from string import Formatter
  from markupsafe import EscapeFormatter
  from markupsafe import Markup
  from .environment import Environment
  from .exceptions import SecurityError
  from .runtime import Context
  from .runtime import Undefined
label_desc: Use image node_id 9 for calling the SandboxedEnvironment obj's underlying member method code with example usage: obj.format_string(s, args, kwargs, format_func) and returns: type