Repository: kudu Updated Branches: refs/heads/master fb512261f -> e0c6ced3e
KUDU-1654 - [python] Python 3 Client Test Failure: test_table_column Python 3 fails the test_table_column test because it is is attempting to cast a string to bytes without an encoding argument. In Python 3, this is a required parameter as bytes and strings are no longer synonymous. This patch utilizes the kudu.compat.frombytes method which was written for this purpose. Change-Id: I7184639426b7f2528523209152dafd5fa39fecf9 Reviewed-on: http://gerrit.cloudera.org:8080/4543 Tested-by: Kudu Jenkins Reviewed-by: David Ribeiro Alves <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/kudu/repo Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/5935697e Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/5935697e Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/5935697e Branch: refs/heads/master Commit: 5935697e073b698f96f1c3a981347a8c949ca6ad Parents: fb51226 Author: Jordan Birdsell <[email protected]> Authored: Tue Sep 27 08:31:54 2016 -0400 Committer: Todd Lipcon <[email protected]> Committed: Tue Oct 4 00:58:02 2016 +0000 ---------------------------------------------------------------------- python/kudu/client.pyx | 11 ++++++----- python/kudu/tests/test_client.py | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kudu/blob/5935697e/python/kudu/client.pyx ---------------------------------------------------------------------- diff --git a/python/kudu/client.pyx b/python/kudu/client.pyx index ebe2ff5..0f64c92 100644 --- a/python/kudu/client.pyx +++ b/python/kudu/client.pyx @@ -719,18 +719,18 @@ cdef class Column: scanner.add_predicate(table[col_name] <= 10) """ cdef readonly: - object name Table parent ColumnSchema spec + str name def __cinit__(self, Table parent, ColumnSchema spec): - self.name = tobytes(spec.name) + self.name = spec.name self.parent = parent self.spec = spec def __repr__(self): result = ('Column({0}, parent={1}, type={2})' - .format(frombytes(self.name), + .format(self.name, self.parent.name, self.spec.type.name)) return result @@ -763,9 +763,10 @@ cdef class Column: Slice* col_name_slice ComparisonOp cmp_op Predicate result + object _name = tobytes(self.name) - col_name_slice = new Slice(<char*> self.name, - len(self.name)) + col_name_slice = new Slice(<char*> _name, + len(_name)) try: if op == 0: # < http://git-wip-us.apache.org/repos/asf/kudu/blob/5935697e/python/kudu/tests/test_client.py ---------------------------------------------------------------------- diff --git a/python/kudu/tests/test_client.py b/python/kudu/tests/test_client.py index e900fd7..b396d94 100644 --- a/python/kudu/tests/test_client.py +++ b/python/kudu/tests/test_client.py @@ -42,7 +42,7 @@ class TestClient(KuduTestBase, unittest.TestCase): (table[-1], 'unixtime_micros_val', 'unixtime_micros')] for col, name, type in cols: - assert col.name == bytes(name) + assert col.name == name assert col.parent is table result_repr = repr(col)
