diff --git a/tests/test_protocol_cybinary.py b/tests/test_protocol_cybinary.py index c8ed157..e074048 100644 --- a/tests/test_protocol_cybinary.py +++ b/tests/test_protocol_cybinary.py @@ -22,8 +22,8 @@ class TItem(TPayload): thrift_spec = { - 1: (TType.I32, "id"), - 2: (TType.LIST, "phones", (TType.STRING)), + 1: (TType.I32, "id", False), + 2: (TType.LIST, "phones", TType.STRING, False), } default_spec = [("id", None), ("phones", None)] @@ -214,8 +214,8 @@ def test_read_huge_args(): class Hello(TPayload): thrift_spec = { - 1: (TType.STRING, "name"), - 2: (TType.STRING, "world"), + 1: (TType.STRING, "name", False), + 2: (TType.STRING, "world", False), } default_spec = [("name", None), ("world", None)] @@ -346,8 +346,8 @@ def test_read_wrong_arg_type(): class TWrongTypeItem(TPayload): thrift_spec = { - 1: (TType.STRING, "id"), - 2: (TType.LIST, "phones", (TType.STRING)), + 1: (TType.STRING, "id", False), + 2: (TType.LIST, "phones", TType.STRING, False), } default_spec = [("id", None), ("phones", None)] diff --git a/tests/test_tracking.py b/tests/test_tracking.py index 2395324..d9c3fcf 100644 --- a/tests/test_tracking.py +++ b/tests/test_tracking.py @@ -61,6 +61,10 @@ def remove(self, name): c.add(person) return True + def get_phonenumbers(self, name, count): + return [addressbook.PhoneNumber(number="sdaf"), + addressbook.PhoneNumber(number='saf')] + def add(self, person): with client(port=6099) as c: c.hello("jane") @@ -266,6 +270,9 @@ def test_tracked_client_not_tracked_server(not_tracked_server): assert c._upgraded is False c.ping() c.hello("cat") + a = c.get_phonenumbers("hello", 54) + assert len(a) == 2 + assert a[0].number == 'sdaf' and a[1].number == 'saf' def test_request_id_func(): diff --git a/thriftpy/protocol/cybin/cybin.pyx b/thriftpy/protocol/cybin/cybin.pyx index 72915dd..a5e51fd 100644 --- a/thriftpy/protocol/cybin/cybin.pyx +++ b/thriftpy/protocol/cybin/cybin.pyx @@ -118,7 +118,7 @@ cdef inline read_struct(CyTransportBase buf, obj): continue name = field_spec[1] - if len(field_spec) == 2: + if len(field_spec) <= 3: spec = None else: spec = field_spec[2] @@ -138,7 +138,7 @@ cdef inline write_struct(CyTransportBase buf, obj): for fid, field_spec in thrift_spec.items(): f_type = field_spec[0] f_name = field_spec[1] - if len(field_spec) == 2: + if len(field_spec) <= 3: container_spec = None else: container_spec = field_spec[2] diff --git a/thriftpy/thrift.py b/thriftpy/thrift.py index ffbed4e..9b64ed9 100644 --- a/thriftpy/thrift.py +++ b/thriftpy/thrift.py @@ -318,8 +318,8 @@ class TApplicationException(TException): """Application level thrift exceptions.""" thrift_spec = { - 1: (TType.STRING, 'message'), - 2: (TType.I32, 'type'), + 1: (TType.STRING, 'message', False), + 2: (TType.I32, 'type', False), } UNKNOWN = 0