[diffoscope] 05/10: {feeders/diff/command}: fixes FIFO writting and parsing from stdout

Juliana Oliveira jwnx-guest at moszumanska.debian.org
Mon Jan 29 03:43:23 CET 2018


This is an automated email from the git hooks/post-receive script.

jwnx-guest pushed a commit to branch jwnx_subprocess_merge
in repository diffoscope.

commit 16286610077507d0a4e1d55f69675113fb5ed689
Author: Juliana Oliveira <juliana.orod at gmail.com>
Date:   Mon Jan 22 17:46:07 2018 -0200

    {feeders/diff/command}: fixes FIFO writting and parsing from stdout
    
    Since Popen was replaced by subprocess.run in Command, stdout and stderr
    were simplified. Sometimes, this change reflected on how output was being
    written on file. As Feeder and Diff were expecting a different
    kind of Command.stdout, they were unable to parse some temporary files, which
    caused a few tests to fail (and mostly fallback) without errors.
    
    This patch fixes Command.stdout formatting and Feeder and Diff
    writting/parsing of files.
    
    Signed-off-by: Juliana Oliveira <juliana.orod at gmail.com>
---
 diffoscope/comparators/utils/command.py | 2 +-
 diffoscope/diff.py                      | 4 ++--
 diffoscope/feeders.py                   | 3 ++-
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/diffoscope/comparators/utils/command.py b/diffoscope/comparators/utils/command.py
index c276bfe..9abc158 100644
--- a/diffoscope/comparators/utils/command.py
+++ b/diffoscope/comparators/utils/command.py
@@ -102,4 +102,4 @@ class Command(object, metaclass=abc.ABCMeta):
 
     @property
     def stdout(self):
-        return [self._process.stdout]
+        return self._process.stdout.decode().splitlines(True)
diff --git a/diffoscope/diff.py b/diffoscope/diff.py
index f21aa45..5664caa 100644
--- a/diffoscope/diff.py
+++ b/diffoscope/diff.py
@@ -67,8 +67,8 @@ class DiffParser(object):
         return self._success
 
     def parse(self):
-        for line in self._output:
-            self._action = self._action(line.decode('utf-8', errors='replace'))
+        for line in self._output.decode('utf-8', errors='replace').splitlines(True):
+            self._action = self._action(line)
 
         self._action('')
         self._success = True
diff --git a/diffoscope/feeders.py b/diffoscope/feeders.py
index 8522584..04a3440 100644
--- a/diffoscope/feeders.py
+++ b/diffoscope/feeders.py
@@ -43,6 +43,7 @@ def from_raw_reader(in_file, filter=None):
             h = hashlib.sha1()
 
         for buf in in_file:
+            buf = buf.encode('utf-8')
             line_count += 1
             out = buf if filter is None else filter(buf)
 
@@ -71,7 +72,7 @@ def from_raw_reader(in_file, filter=None):
 def from_text_reader(in_file, filter=None):
     if filter is None:
         def encoding_filter(text_buf):
-            return text_buf.encode('utf-8')
+            return text_buf
     else:
         def encoding_filter(text_buf):
             return filter(text_buf).encode('utf-8')

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git


More information about the diffoscope mailing list