One function

RepeatedField in eigenein/protobuf

The author described this change as Fix repeated byte string field being read as a packed field. It counts as a record because the check below fails on the code as it stood at bdcfa78b8 and passes on 98a69bf41, with nothing else changed between the two runs.

Fix saved2019-03-26
Sharing licenceMIT · LICENSE
Change size+4 4

What the code was meant to do, written into the code itself as a docstring

Handles repeated and packed repeated field. See also: https://developers.google.com/protocol-buffers/docs/encoding#optional

The change

99 self.serializer.validate(item)
1010
1111 def load(self, wire_type: WireType, io: IO) -> Any:
12- # Protocol buffer parsers must be able to parse repeated fields
13- # that were compiled as packed as if they were not packed, and vice versa.
14- # See also: https://developers.google.com/protocol-buffers/docs/encoding#packed
15- if wire_type == WireType.BYTES:
12+ if self.serializer.wire_type != WireType.BYTES and wire_type == WireType.BYTES:
13+ # Protocol buffer parsers must be able to parse repeated fields
14+ # that were compiled as packed as if they were not packed, and vice versa.
15+ # See also: https://developers.google.com/protocol-buffers/docs/encoding#packed
1616 return list(self.load_packed(bytes_serializer.load(io)))
1717 if wire_type == self.serializer.wire_type:
1818 return [self.serializer.load(io)]

The check that tells the two apart

failpass·tests/test_fields.py::test_unpacked_repeated_field_load[serializer1-value1-\x04None]

Check file tests/test_fields.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before itbdcfa78b8fc5cab10ecfb4e65e89493ccae2eabd
Broken version dated2019-03-26
Modulepure_protobuf.fields
Units changedRepeatedField
Fingerprintce7d4ed0aae356ab
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.