Skip to content
This repository has been archived by the owner on Dec 10, 2018. It is now read-only.

Commit

Permalink
Merge pull request #194 from wbolster/propagate-decode-response-flag-…
Browse files Browse the repository at this point in the history
…for-container-types

Propagate decode_response to nested structs
  • Loading branch information
lxyu committed Mar 30, 2016
2 parents c938b44 + ed1d0cc commit d9afc32
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
8 changes: 4 additions & 4 deletions thriftpy/protocol/binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def read_val(inbuf, ttype, spec=None, decode_response=True):
return []

for i in range(sz):
result.append(read_val(inbuf, v_type, v_spec))
result.append(read_val(inbuf, v_type, v_spec, decode_response))
return result

elif ttype == TType.MAP:
Expand All @@ -277,15 +277,15 @@ def read_val(inbuf, ttype, spec=None, decode_response=True):
return {}

for i in range(sz):
k_val = read_val(inbuf, k_type, k_spec)
v_val = read_val(inbuf, v_type, v_spec)
k_val = read_val(inbuf, k_type, k_spec, decode_response)
v_val = read_val(inbuf, v_type, v_spec, decode_response)
result[k_val] = v_val

return result

elif ttype == TType.STRUCT:
obj = spec()
read_struct(inbuf, obj)
read_struct(inbuf, obj, decode_response)
return obj


Expand Down
7 changes: 4 additions & 3 deletions thriftpy/protocol/cybin/cybin.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,8 @@ cdef c_read_val(CyTransportBase buf, TType ttype, spec=None,
skip(buf, orig_type)
return []

return [c_read_val(buf, v_type, v_spec) for _ in range(size)]
return [c_read_val(buf, v_type, v_spec, decode_response)
for _ in range(size)]

elif ttype == T_MAP:
key = spec[0]
Expand Down Expand Up @@ -317,11 +318,11 @@ cdef c_read_val(CyTransportBase buf, TType ttype, spec=None,
skip(buf, orig_type)
return {}

return {c_read_val(buf, k_type, k_spec): c_read_val(buf, v_type, v_spec)
return {c_read_val(buf, k_type, k_spec, decode_response): c_read_val(buf, v_type, v_spec, decode_response)
for _ in range(size)}

elif ttype == T_STRUCT:
return read_struct(buf, spec())
return read_struct(buf, spec(), decode_response)


cdef c_write_val(CyTransportBase buf, TType ttype, val, spec=None):
Expand Down

0 comments on commit d9afc32

Please sign in to comment.