| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 46201b3 commit 08a0fad
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -307,19 +307,28 @@ def __del__(self): | |||
| 307 | 307 | def __getattr__(self, attr): | |
| 308 | 308 | return getattr(self.proc, attr) | |
| 309 | 309 | ||
| 310 | - def wait(self, stderr=''): | ||
| 310 | + def wait(self, stderr=b''): | ||
| 311 | 311 | """Wait for the process and return its status code. | |
| 312 | 312 | ||
| 313 | 313 | :param stderr: Previously read value of stderr, in case stderr is already closed. | |
| 314 | 314 | :warn: may deadlock if output or error pipes are used and not handled separately. | |
| 315 | 315 | :raise GitCommandError: if the return status is not 0""" | |
| 316 | + | ||
| 317 | + # stderr must be a bytes object as it will | ||
| 318 | + # combined with more data from the process and | ||
| 319 | + # decoded by the caller | ||
| 320 | + if stderr is None: | ||
| 321 | + stderr = b'' | ||
| 322 | + elif type(stderr) == unicode: | ||
| 323 | + stderr = stderr.encode(defenc) | ||
| 324 | + | ||
| 316 | 325 | status = self.proc.wait() | |
| 317 | 326 | ||
| 318 | 327 | def read_all_from_possibly_closed_stream(stream): | |
| 319 | 328 | try: | |
| 320 | 329 | return stderr + stream.read() | |
| 321 | 330 | except ValueError: | |
| 322 | - return stderr or '' | ||
| 331 | + return stderr or b'' | ||
| 323 | 332 | ||
| 324 | 333 | if status != 0: | |
| 325 | 334 | errstr = read_all_from_possibly_closed_stream(self.proc.stderr) | |
@@ -678,7 +687,7 @@ def _kill_process(pid): | |||
| 678 | 687 | # strip trailing "\n" | |
| 679 | 688 | if stderr_value.endswith(b"\n"): | |
| 680 | 689 | stderr_value = stderr_value[:-1] | |
| 681 | - status = proc.wait(stderr=stderr_value) | ||
| 690 | + status = proc.wait() | ||
| 682 | 691 | # END stdout handling | |
| 683 | 692 | finally: | |
| 684 | 693 | proc.stdout.close() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -772,10 +772,10 @@ def done(self): | |||
| 772 | 772 | self.cv.notify_all() | |
| 773 | 773 | self.cv.release() | |
| 774 | 774 | ||
| 775 | - def wait(self): | ||
| 775 | + def wait(self, stderr=b''): | ||
| 776 | 776 | self.cv.acquire() | |
| 777 | 777 | while self.count > 0: | |
| 778 | - self.cv.wait() | ||
| 778 | + self.cv.wait(strerr=stderr) | ||
| 779 | 779 | self.cv.release() | |
| 780 | 780 | ||
| 781 | 781 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments