|
20 | 20 | import threading |
21 | 21 | import warnings |
22 | 22 |
|
23 | | -from git.compat import defenc, force_bytes, safe_decode |
| 23 | +from git.compat import defenc, safe_decode |
24 | 24 | from git.exc import ( |
25 | 25 | CommandError, |
26 | 26 | GitCommandError, |
@@ -109,7 +109,7 @@ def handle_process_output( |
109 | 109 | stderr_handler: Union[None, Callable[[AnyStr], None], Callable[[List[AnyStr]], None]], |
110 | 110 | finalizer: Union[None, Callable[[Union[Popen, "Git.AutoInterrupt"]], None]] = None, |
111 | 111 | decode_streams: bool = True, |
112 | | - kill_after_timeout: float | int | None = None, |
| 112 | + kill_after_timeout: float | None = None, |
113 | 113 | ) -> None: |
114 | 114 | R"""Register for notifications to learn that process output is ready to read, and |
115 | 115 | dispatch lines to the respective line handlers. |
@@ -335,7 +335,7 @@ def __init__( |
335 | 335 | self, |
336 | 336 | proc: subprocess.Popen | None, |
337 | 337 | args: Any, |
338 | | - timeout: float | int | None = None, |
| 338 | + timeout: float | None = None, |
339 | 339 | ) -> None: |
340 | 340 | self.proc = proc |
341 | 341 | self.args = args |
@@ -387,47 +387,6 @@ def __del__(self) -> None: |
387 | 387 | def __getattr__(self, attr: str) -> Any: |
388 | 388 | return getattr(self.proc, attr) |
389 | 389 |
|
390 | | - # TODO: Bad choice to mimic `proc.wait()` but with different args. |
391 | | - def wait(self, stderr: Union[None, str, bytes] = b"") -> int: |
392 | | - """Wait for the process and return its status code. |
393 | | -
|
394 | | - :param stderr: |
395 | | - Previously read value of stderr, in case stderr is already closed. |
396 | | -
|
397 | | - :warn: |
398 | | - May deadlock if output or error pipes are used and not handled separately. |
399 | | -
|
400 | | - :raise git.exc.GitCommandError: |
401 | | - If the return status is not 0. |
402 | | - """ |
403 | | - if stderr is None: |
404 | | - stderr_b = b"" |
405 | | - stderr_b = force_bytes(data=stderr, encoding="utf-8") |
406 | | - status: Union[int, None] |
407 | | - if self.proc is not None: |
408 | | - status = self.proc.wait(timeout=self.timeout) |
409 | | - p_stderr = self.proc.stderr |
410 | | - else: # Assume the underlying proc was killed earlier or never existed. |
411 | | - status = self.status |
412 | | - p_stderr = None |
413 | | - |
414 | | - def read_all_from_possibly_closed_stream(stream: Union[IO[bytes], None]) -> bytes: |
415 | | - if stream: |
416 | | - try: |
417 | | - return stderr_b + force_bytes(stream.read()) |
418 | | - except (OSError, ValueError): |
419 | | - return stderr_b or b"" |
420 | | - else: |
421 | | - return stderr_b or b"" |
422 | | - |
423 | | - # END status handling |
424 | | - |
425 | | - if status != 0: |
426 | | - errstr = read_all_from_possibly_closed_stream(p_stderr) |
427 | | - _logger.debug("AutoInterrupt wait stderr: %r" % (errstr,)) |
428 | | - raise GitCommandError(remove_password_if_present(self.args), status, errstr) |
429 | | - return status |
430 | | - |
431 | 390 |
|
432 | 391 | _AutoInterrupt.__name__ = "AutoInterrupt" |
433 | 392 | _AutoInterrupt.__qualname__ = "Git.AutoInterrupt" |
@@ -1111,7 +1070,7 @@ def execute( |
1111 | 1070 | as_process: bool = False, |
1112 | 1071 | output_stream: Union[None, BinaryIO] = None, |
1113 | 1072 | stdout_as_string: bool = True, |
1114 | | - kill_after_timeout: float | int | None = None, |
| 1073 | + kill_after_timeout: float | None = None, |
1115 | 1074 | with_stdout: bool = True, |
1116 | 1075 | universal_newlines: bool = False, |
1117 | 1076 | shell: Union[None, bool] = None, |
|
0 commit comments