MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / get_exec_path

Function get_exec_path

tools/python-3.11.9-amd64/Lib/os.py:619–660  ·  view source on GitHub ↗

Returns the sequence of directories that will be searched for the named executable (similar to a shell) when launching a process. *env* must be an environment variable dict or None. If *env* is None, os.environ will be used.

(env=None)

Source from the content-addressed store, hash-verified

617
618
619def get_exec_path(env=None):
620 """Returns the sequence of directories that will be searched for the
621 named executable (similar to a shell) when launching a process.
622
623 *env* must be an environment variable dict or None. If *env* is None,
624 os.environ will be used.
625 """
626 # Use a local import instead of a global import to limit the number of
627 # modules loaded at startup: the os module is always loaded at startup by
628 # Python. It may also avoid a bootstrap issue.
629 import warnings
630
631 if env is None:
632 env = environ
633
634 # {b'PATH': ...}.get('PATH') and {'PATH': ...}.get(b'PATH') emit a
635 # BytesWarning when using python -b or python -bb: ignore the warning
636 with warnings.catch_warnings():
637 warnings.simplefilter("ignore", BytesWarning)
638
639 try:
640 path_list = env.get('PATH')
641 except TypeError:
642 path_list = None
643
644 if supports_bytes_environ:
645 try:
646 path_listb = env[b'PATH']
647 except (KeyError, TypeError):
648 pass
649 else:
650 if path_list is not None:
651 raise ValueError(
652 "env cannot contain 'PATH' and b'PATH' keys")
653 path_list = path_listb
654
655 if path_list is not None and isinstance(path_list, bytes):
656 path_list = fsdecode(path_list)
657
658 if path_list is None:
659 path_list = defpath
660 return path_list.split(pathsep)
661
662
663# Change environ to automatically call putenv() and unsetenv()

Callers 1

_execvpeFunction · 0.85

Calls 3

fsdecodeFunction · 0.70
getMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected