[Buildroot] [PATCH v2 03/10] autobuild-run, python3: decode subprocess output

André Erdmann dywi at mailerd.de
Wed Mar 18 15:50:36 UTC 2015


subprocess.check_output() and its py 2.6 compat variant,
subprocess.Popen().communicate()[0], return a bytes object in Python 3,
but regexp.search() in get_failure_reason() wants a str:

  >>> re.search(r'.', b'a')
  TypeError: can't use a string pattern on a bytes-like object

Signed-off-by: André Erdmann <dywi at mailerd.de>
---
 scripts/autobuild-run | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/scripts/autobuild-run b/scripts/autobuild-run
index 1edffc1..e536289 100755
--- a/scripts/autobuild-run
+++ b/scripts/autobuild-run
@@ -576,8 +576,9 @@ def send_results(result, **kwargs):
 
     def get_failure_reason():
         # Output is a tuple (package, version), or None.
-        lastlines = subprocess.Popen(["tail", "-n", "3",
-                                      os.path.join(outputdir, "logfile")], stdout=subprocess.PIPE).communicate()[0].splitlines()
+        lastlines = decode_bytes(subprocess.Popen(
+            ["tail", "-n", "3", os.path.join(outputdir, "logfile")],
+            stdout=subprocess.PIPE).communicate()[0]).splitlines()
 
         import re
         regexp = re.compile(r'make: \*\*\* .*/(?:build|toolchain)/([^/]*)/')
-- 
2.3.2



More information about the buildroot mailing list