code: def escape(pathname):
      
      # Escaping is done by wrapping any of "*?[" between square brackets.
      # Metacharacters do not work in the drive part and shouldn't be escaped.
      drive, pathname = os.path.splitdrive(pathname)
      if isinstance(pathname, bytes):
          pathname = magic_check_bytes.sub(br'[\1]', pathname)
      else:
          pathname = magic_check.sub(r'[\1]', pathname)
      return drive + pathname
docs: Escape all special characters.