byte fields were deserialized incorrectly
This commit is contained in:
Erik Friese 2023-09-05 20:26:46 +02:00
parent 8f535913a1
commit 0931eb3bf5
2 changed files with 4 additions and 2 deletions

View File

@ -39,7 +39,7 @@ fn map_field_value(field_name: &str, field_value: Value, proto_meta: &PyAny) ->
let py = proto_meta.py();
match field_value {
Value::Bool(x) => Ok(x.to_object(py)),
Value::Bytes(x) => Ok(x.to_object(py)),
Value::Bytes(x) => Ok(PyBytes::new(py, &x).to_object(py)),
Value::F32(x) => Ok(x.to_object(py)),
Value::F64(x) => Ok(x.to_object(py)),
Value::I32(x) => Ok(x.to_object(py)),

View File

@ -32,6 +32,7 @@ class Bar(betterproto.Message):
enm: Enm = betterproto.enum_field(4)
map: Dict[int, bool] = betterproto.map_field(5, betterproto.TYPE_INT64, betterproto.TYPE_BOOL)
maybe: Optional[bool] = betterproto.message_field(6, wraps=betterproto.TYPE_BOOL)
bts: bytes = betterproto.bytes_field(7)
# Serialization has not been changed yet. So nothing unusual here
buffer = bytes(
@ -44,7 +45,8 @@ buffer = bytes(
1: True,
42: False
},
maybe=True
maybe=True,
bts=b'Hi There!'
)
)