From 36a4c19494e2cb7e968f1d0e0c09926a660e1a56 Mon Sep 17 00:00:00 2001 From: Krzysztof Gogolewski Date: Mon, 6 Aug 2018 21:38:52 +0200 Subject: Testsuite driver: fix encoding issue when calling ghc-pkg Summary: In Python 3, subprocess.communicate() returns a pair of bytes, which need to be decoded. In runtests.py, we were just calling str() instead, which converts b'x' to "b'x'". As a result, the loop that was checking pkginfo for lines starting with 'library-dirs' couldn't work. Reviewers: bgamari, thomie, Phyx Reviewed By: thomie Subscribers: Phyx, rwbarton, carter Differential Revision: https://phabricator.haskell.org/D5046 --- testsuite/driver/testutil.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'testsuite/driver/testutil.py') diff --git a/testsuite/driver/testutil.py b/testsuite/driver/testutil.py index 104bbffab4..15587e6960 100644 --- a/testsuite/driver/testutil.py +++ b/testsuite/driver/testutil.py @@ -10,8 +10,7 @@ def strip_quotes(s): return s.strip('\'"') def getStdout(cmd_and_args): - # Can't use subprocess.check_output as it's not available in Python 2.6; - # It's also not quite the same as check_output, since we also verify that + # Can't use subprocess.check_output, since we also verify that # no stderr was produced p = subprocess.Popen([strip_quotes(cmd_and_args[0])] + cmd_and_args[1:], stdout=subprocess.PIPE, @@ -22,7 +21,7 @@ def getStdout(cmd_and_args): raise Exception("Command failed: " + str(cmd_and_args)) if stderr: raise Exception("stderr from command: %s\nOutput:\n%s\n" % (cmd_and_args, stderr)) - return stdout + return stdout.decode('utf-8') def lndir(srcdir, dstdir): # Create symlinks for all files in src directory. -- cgit v1.2.1