diff --git a/luigi/contrib/hive.py b/luigi/contrib/hive.py index a310677b12..91c84e320f 100644 --- a/luigi/contrib/hive.py +++ b/luigi/contrib/hive.py @@ -68,7 +68,7 @@ def run_hive(args, check_return_code=True): if check_return_code and p.returncode != 0: raise HiveCommandError("Hive command: {0} failed with error code: {1}".format(" ".join(cmd), p.returncode), stdout, stderr) - return stdout + return stdout.decode('utf-8') def run_hive_cmd(hivecmd, check_return_code=True): diff --git a/test/contrib/hive_test.py b/test/contrib/hive_test.py index 6ae4138470..4cf6655c66 100644 --- a/test/contrib/hive_test.py +++ b/test/contrib/hive_test.py @@ -32,7 +32,7 @@ class HiveTest(unittest.TestCase): def mock_hive_cmd(self, args, check_return=True): self.last_hive_cmd = args self.count += 1 - return "statement{0}".format(self.count) + return six.u("statement{0}".format(self.count)) def setUp(self): self.run_hive_cmd_saved = luigi.contrib.hive.run_hive @@ -262,7 +262,7 @@ def test_run_hive_command(self, popen): # I'm testing this again to check the return codes # I didn't want to tear up all the existing tests to change how run_hive is mocked comm = mock.Mock(name='communicate_mock') - comm.return_value = "some return stuff", "" + comm.return_value = six.b("some return stuff"), "" preturn = mock.Mock(name='open_mock') preturn.returncode = 0 @@ -275,7 +275,7 @@ def test_run_hive_command(self, popen): preturn.returncode = 17 self.assertRaises(luigi.contrib.hive.HiveCommandError, luigi.contrib.hive.run_hive, ["blah", "blah"]) - comm.return_value = "", "some stderr stuff" + comm.return_value = six.b(""), "some stderr stuff" returned = luigi.contrib.hive.run_hive(["blah", "blah"], False) self.assertEqual("", returned)