bugfix: parsing unknown fields properly
This commit is contained in:
parent
2d30bdb7b2
commit
219233b50e
@ -3,7 +3,7 @@ use crate::{
|
|||||||
py_any_extras::PyAnyExtras,
|
py_any_extras::PyAnyExtras,
|
||||||
};
|
};
|
||||||
use prost_reflect::{DynamicMessage, Value};
|
use prost_reflect::{DynamicMessage, Value};
|
||||||
use pyo3::{PyAny, PyObject, ToPyObject};
|
use pyo3::{PyAny, PyObject, ToPyObject, types::PyBytes};
|
||||||
|
|
||||||
pub fn merge_msg_into_pyobj(obj: &PyAny, mut msg: DynamicMessage) -> Result<()> {
|
pub fn merge_msg_into_pyobj(obj: &PyAny, mut msg: DynamicMessage) -> Result<()> {
|
||||||
for field in msg.take_fields() {
|
for field in msg.take_fields() {
|
||||||
@ -22,7 +22,7 @@ pub fn merge_msg_into_pyobj(obj: &PyAny, mut msg: DynamicMessage) -> Result<()>
|
|||||||
if !buf.is_empty() {
|
if !buf.is_empty() {
|
||||||
let mut unknown_fields = obj.getattr("_unknown_fields")?.extract::<Vec<u8>>()?;
|
let mut unknown_fields = obj.getattr("_unknown_fields")?.extract::<Vec<u8>>()?;
|
||||||
unknown_fields.append(&mut buf);
|
unknown_fields.append(&mut buf);
|
||||||
obj.setattr("_unknown_fields", unknown_fields)?;
|
obj.setattr("_unknown_fields", PyBytes::new(obj.py(), &unknown_fields))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
obj.setattr("_serialized_on_wire", true)?;
|
obj.setattr("_serialized_on_wire", true)?;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user