code: def pop_path_info(environ, charset="utf-8", errors="replace"):
      """Removes and returns the next segment of `PATH_INFO`, pushing it onto
      `SCRIPT_NAME`.  Returns `None` if there is nothing left on `PATH_INFO`.
      If the `charset` is set to `None` bytes are returned.
      If there are empty segments (``'/foo//bar``) these are ignored but
      properly pushed to the `SCRIPT_NAME`:
      >>> env = {'SCRIPT_NAME': '/foo', 'PATH_INFO': '/a/b'}
      >>> pop_path_info(env)
      'a'
      >>> env['SCRIPT_NAME']
      '/foo/a'
      >>> pop_path_info(env)
      'b'
      >>> env['SCRIPT_NAME']
      '/foo/a/b'
      .. deprecated:: 2.2
          Will be removed in Werkzeug 2.3.
      .. versionadded:: 0.5
      .. versionchanged:: 0.9
         The path is now decoded and a charset and encoding
         parameter can be provided.
      :param environ: the WSGI environment that is modified.
      :param charset: The ``encoding`` parameter passed to
          :func:`bytes.decode`.
      :param errors: The ``errors`` paramater passed to
          :func:`bytes.decode`.
      """
  
      path = get_path_info(environ)
      if not path:
          return None
  
      script_name = environ.get("SCRIPT_NAME", "")
  
      # shift multiple leading slashes over
      old_path = path
      path = path.lstrip("/")
      if path != old_path:
          script_name += "/" * (len(old_path) - len(path))
  
      if "/" not in path:
          environ["PATH_INFO"] = ""
          environ["SCRIPT_NAME"] = script_name + path
          rv = path.encode("latin1")
      else:
          segment, path = path.split("/", 1)
          environ["PATH_INFO"] = "/{}".format(path)
          environ["SCRIPT_NAME"] = script_name + segment
          rv = segment.encode("latin1")
  
      return _to_str(rv, charset, errors, allow_none_charset=True)
  
file_path: dtale/dtale/django/dispatcher.py
imports: import sys
  from threading import Lock
  from werkzeug.wsgi import get_path_info
label_desc: Use image node_id 2 for calling a global function with example usage: pop_path_info(environ, charset, errors) and returns: _to_str, None