thriftpy icon indicating copy to clipboard operation
thriftpy copied to clipboard

add TDecodeException to pure python binary.py's write_struct

Open pawl opened this issue 7 years ago • 0 comments

The pure python binary protocol will throw errors like this when it's unable to decode a value:

AttributeError: 'int' object has no attribute 'encode'

The cython version of the binary protocol throws more helpful errors like this:

ERROR:thriftpy.server:Field 'success(0)' of 'ping_result' needs type 'STRING', but the value is `123`

This changes the pure python version to behave more like the cython version.

This PR also refactors write_val in thriftpy/protocol/binary.py to look similar to c_write_val in thriftpy/protocol/cybin/cybin.c.

pawl avatar Mar 21 '17 04:03 pawl