Execute program (MS Windows version)
(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
unused_restore_signals,
unused_gid, unused_gids, unused_uid,
unused_umask,
unused_start_new_session, unused_process_group)
| 1502 | |
| 1503 | |
| 1504 | def _execute_child(self, args, executable, preexec_fn, close_fds, |
| 1505 | pass_fds, cwd, env, |
| 1506 | startupinfo, creationflags, shell, |
| 1507 | p2cread, p2cwrite, |
| 1508 | c2pread, c2pwrite, |
| 1509 | errread, errwrite, |
| 1510 | unused_restore_signals, |
| 1511 | unused_gid, unused_gids, unused_uid, |
| 1512 | unused_umask, |
| 1513 | unused_start_new_session, unused_process_group): |
| 1514 | """Execute program (MS Windows version)""" |
| 1515 | |
| 1516 | assert not pass_fds, "pass_fds not supported on Windows." |
| 1517 | |
| 1518 | if isinstance(args, str): |
| 1519 | pass |
| 1520 | elif isinstance(args, bytes): |
| 1521 | if shell: |
| 1522 | raise TypeError('bytes args is not allowed on Windows') |
| 1523 | args = list2cmdline([args]) |
| 1524 | elif isinstance(args, os.PathLike): |
| 1525 | if shell: |
| 1526 | raise TypeError('path-like args is not allowed when ' |
| 1527 | 'shell is true') |
| 1528 | args = list2cmdline([args]) |
| 1529 | else: |
| 1530 | args = list2cmdline(args) |
| 1531 | |
| 1532 | if executable is not None: |
| 1533 | executable = os.fsdecode(executable) |
| 1534 | |
| 1535 | # Process startup details |
| 1536 | if startupinfo is None: |
| 1537 | startupinfo = STARTUPINFO() |
| 1538 | else: |
| 1539 | # bpo-34044: Copy STARTUPINFO since it is modified above, |
| 1540 | # so the caller can reuse it multiple times. |
| 1541 | startupinfo = startupinfo.copy() |
| 1542 | |
| 1543 | use_std_handles = -1 not in (p2cread, c2pwrite, errwrite) |
| 1544 | if use_std_handles: |
| 1545 | startupinfo.dwFlags |= _winapi.STARTF_USESTDHANDLES |
| 1546 | startupinfo.hStdInput = p2cread |
| 1547 | startupinfo.hStdOutput = c2pwrite |
| 1548 | startupinfo.hStdError = errwrite |
| 1549 | |
| 1550 | attribute_list = startupinfo.lpAttributeList |
| 1551 | have_handle_list = bool(attribute_list and |
| 1552 | "handle_list" in attribute_list and |
| 1553 | attribute_list["handle_list"]) |
| 1554 | |
| 1555 | # If we were given an handle_list or need to create one |
| 1556 | if have_handle_list or (use_std_handles and close_fds): |
| 1557 | if attribute_list is None: |
| 1558 | attribute_list = startupinfo.lpAttributeList = {} |
| 1559 | handle_list = attribute_list["handle_list"] = \ |
| 1560 | list(attribute_list.get("handle_list", [])) |
| 1561 |
no test coverage detected