Whole file

mikiepure/pydlt

The author described this change as Fix bug that encoding can be ignored when reading DLT file. It counts as a record because the check below fails on the code as it stood at 10d4418c4 and passes on 476c9899c, with nothing else changed between the two runs.

Fix saved2024-03-24
Sharing licenceMIT · LICENSE
Change size+4 2

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

Fix bug that encoding can be ignored when reading DLT file

The change

739739 Args:
740740 data (str): A data payload of string.
741741 is_utf8 (bool, optional): Encoding of the string is UTF-8 if True, or ASCII.
742- Defaults to True (UTF-8).
742+ Defaults to False (ASCII).
743743 msb_first (Optional[bool], optional): [description]. Defaults to None.
744744 encoding: custom 8-bit encoding that will be used for serialization
745745 Has no effect if is_utf8 is set to True
769769 ) -> "Argument":
770770 endian = ">" if msb_first else "<"
771771 length = struct.unpack(f"{endian}H", data_payload[: cls.LENGTH_SIZE])[0]
772+ encoding_format = cls._encoding_format(is_utf8, encoding)
772773 return cls(
773774 data_payload[cls.LENGTH_SIZE : cls.LENGTH_SIZE + length - 1].decode(
774- cls._encoding_format(is_utf8, encoding), "replace"
775+ encoding_format, "replace"
775776 ),
776777 is_utf8,
777778 msb_first,
779+ encoding_format,
778780 )
779781
780782 @property

The check that tells the two apart

failpass·tests/test_file.py::test_file_encoding_utf8

Check file tests/test_file.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 it10d4418c4d5857a88a25ddceb0d609d2489f95a9
Broken version dated2023-11-07
Modulepydlt.payload
Units changedArgumentString
Fingerprintaee71f9360b48797
Checked2026-08-18 by goldset/0.1

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