code: def _find_executable(prog, pathext=("",)):
      
      pathlist = _decode_if_not_text(os.environ.get('PATH', '')).split(os.pathsep)
  
      for dir in pathlist:
          for ext in pathext:
              filename = os.path.join(dir, prog + ext)
              try:
                  st = os.stat(filename)
              except os.error:
                  continue
              if stat.S_ISREG(st.st_mode) and (stat.S_IMODE(st.st_mode) & 0o111):
                  return filename
      return None
docs: protected