MCPcopy Index your code
hub / github.com/python/cpython / __init__

Method __init__

Lib/subprocess.py:870–1128  ·  view source on GitHub ↗

Create new Popen instance.

(self, args, bufsize=-1, executable=None,
                 stdin=None, stdout=None, stderr=None,
                 preexec_fn=None, close_fds=True,
                 shell=False, cwd=None, env=None, universal_newlines=None,
                 startupinfo=None, creationflags=0,
                 restore_signals=True, start_new_session=False,
                 pass_fds=(), *, user=None, group=None, extra_groups=None,
                 encoding=None, errors=None, text=None, umask=-1, pipesize=-1,
                 process_group=None)

Source from the content-addressed store, hash-verified

868 _child_created = False # Set here since __del__ checks it
869
870 def __init__(self, args, bufsize=-1, executable=None,
871 stdin=None, stdout=None, stderr=None,
872 preexec_fn=None, close_fds=True,
873 shell=False, cwd=None, env=None, universal_newlines=None,
874 startupinfo=None, creationflags=0,
875 restore_signals=True, start_new_session=False,
876 pass_fds=(), *, user=None, group=None, extra_groups=None,
877 encoding=None, errors=None, text=None, umask=-1, pipesize=-1,
878 process_group=None):
879 """Create new Popen instance."""
880 if not _can_fork_exec:
881 raise OSError(
882 errno.ENOTSUP, f"{sys.platform} does not support processes."
883 )
884
885 _cleanup()
886 # Held while anything is calling waitpid before returncode has been
887 # updated to prevent clobbering returncode if wait() or poll() are
888 # called from multiple threads at once. After acquiring the lock,
889 # code must re-check self.returncode to see if another thread just
890 # finished a waitpid() call.
891 self._waitpid_lock = threading.Lock()
892
893 self._input = None
894 self._communication_started = False
895 if bufsize is None:
896 bufsize = -1 # Restore default
897 if not isinstance(bufsize, int):
898 raise TypeError("bufsize must be an integer")
899
900 if stdout is STDOUT:
901 raise ValueError("STDOUT can only be used for stderr")
902
903 if pipesize is None:
904 pipesize = -1 # Restore default
905 if not isinstance(pipesize, int):
906 raise TypeError("pipesize must be an integer")
907
908 if _mswindows:
909 if preexec_fn is not None:
910 raise ValueError("preexec_fn is not supported on Windows "
911 "platforms")
912 else:
913 # POSIX
914 if pass_fds and not close_fds:
915 warnings.warn("pass_fds overriding close_fds.", RuntimeWarning)
916 close_fds = True
917 if startupinfo is not None:
918 raise ValueError("startupinfo is only supported on Windows "
919 "platforms")
920 if creationflags != 0:
921 raise ValueError("creationflags is only supported on Windows "
922 "platforms")
923
924 self.args = args
925 self.stdin = None
926 self.stdout = None
927 self.stderr = None

Callers

nothing calls this directly

Calls 14

_get_handlesMethod · 0.95
_execute_childMethod · 0.95
SubprocessErrorClass · 0.85
_text_encodingFunction · 0.85
LockMethod · 0.80
DetachMethod · 0.80
CloseMethod · 0.80
_cleanupFunction · 0.70
filterFunction · 0.70
warnMethod · 0.45
formatMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected