diff options
Diffstat (limited to 'git')
-rw-r--r-- | git/cmd.py | 30 | ||||
-rw-r--r-- | git/exc.py | 3 | ||||
-rw-r--r-- | git/test/lib/helper.py | 3 |
3 files changed, 23 insertions, 13 deletions
@@ -88,18 +88,26 @@ def handle_process_output(process, stdout_handler, stderr_handler, finalizer, de Set it to False if `universal_newline == True` (then streams are in text-mode) or if decoding must happen later (i.e. for Diffs). """ + if decode_streams: + ZERO = b'' + LF = b'\n' + CR = b'\r' + else: + ZERO = u'' + LF = u'\n' + CR = u'\r' def _parse_lines_from_buffer(buf): - line = b'' + line = ZERO bi = 0 lb = len(buf) while bi < lb: - char = _bchr(buf[bi]) + char = buf[bi] bi += 1 - if char in (b'\r', b'\n') and line: - yield bi, line + b'\n' - line = b'' + if char in (LF, CR) and line: + yield bi, line + LF + line = ZERO else: line += char # END process parsed line @@ -107,7 +115,7 @@ def handle_process_output(process, stdout_handler, stderr_handler, finalizer, de # end def _read_lines_from_fno(fno, last_buf_list): - buf = os.read(fno, mmap.PAGESIZE) + buf = fno.read(mmap.PAGESIZE) buf = last_buf_list[0] + buf bi = 0 @@ -192,8 +200,8 @@ def handle_process_output(process, stdout_handler, stderr_handler, finalizer, de else: # poll is preferred, as select is limited to file handles up to 1024 ... . This could otherwise be # an issue for us, as it matters how many handles our own process has - fdmap = {outfn: (stdout_handler, [b''], decode_streams), - errfn: (stderr_handler, [b''], decode_streams)} + fdmap = {outfn: (process.stdout, stdout_handler, [ZERO], decode_streams), + errfn: (process.stderr, stderr_handler, [ZERO], decode_streams)} READ_ONLY = select.POLLIN | select.POLLPRI | select.POLLHUP | select.POLLERR # @UndefinedVariable CLOSED = select.POLLHUP | select.POLLERR # @UndefinedVariable @@ -217,7 +225,7 @@ def handle_process_output(process, stdout_handler, stderr_handler, finalizer, de if result & CLOSED: closed_streams.add(fd) else: - _dispatch_lines(fd, *fdmap[fd]) + _dispatch_lines(*fdmap[fd]) # end handle closed stream # end for each poll-result tuple @@ -227,8 +235,8 @@ def handle_process_output(process, stdout_handler, stderr_handler, finalizer, de # end endless loop # Depelete all remaining buffers - for fno, (handler, buf_list, decode) in fdmap.items(): - _deplete_buffer(fno, handler, buf_list, decode) + for fno, args in fdmap.items(): + _deplete_buffer(*args) # end for each file handle for fno in fdmap.keys(): @@ -34,7 +34,8 @@ class CommandError(UnicodeMixin, Exception): _msg = u"Cmd('%s') failed%s" def __init__(self, command, status=None, stderr=None, stdout=None): - assert isinstance(command, (tuple, list)), command + if not isinstance(command, (tuple, list)): + command = command.split() self.command = command self.status = status if status: diff --git a/git/test/lib/helper.py b/git/test/lib/helper.py index 949e474f..90d2b1e9 100644 --- a/git/test/lib/helper.py +++ b/git/test/lib/helper.py @@ -301,7 +301,8 @@ def with_rw_and_rw_remote_repo(working_tree_ref): try: gd.proc.kill() except: - pass ## Either it has died (and we're here), or it won't die, again here... + ## Either it has died (and we're here), or it won't die, again here... + pass rw_repo.git.clear_cache() rw_remote_repo.git.clear_cache() |