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.
Projectmikiepure/pydlt
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
| 739 | 739 | Args: | |
| 740 | 740 | data (str): A data payload of string. | |
| 741 | 741 | 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). | |
| 743 | 743 | msb_first (Optional[bool], optional): [description]. Defaults to None. | |
| 744 | 744 | encoding: custom 8-bit encoding that will be used for serialization | |
| 745 | 745 | Has no effect if is_utf8 is set to True | |
| ⋯ | |||
| 769 | 769 | ) -> "Argument": | |
| 770 | 770 | endian = ">" if msb_first else "<" | |
| 771 | 771 | length = struct.unpack(f"{endian}H", data_payload[: cls.LENGTH_SIZE])[0] | |
| 772 | + | encoding_format = cls._encoding_format(is_utf8, encoding) | |
| 772 | 773 | return cls( | |
| 773 | 774 | data_payload[cls.LENGTH_SIZE : cls.LENGTH_SIZE + length - 1].decode( | |
| 774 | - | cls._encoding_format(is_utf8, encoding), "replace" | |
| 775 | + | encoding_format, "replace" | |
| 775 | 776 | ), | |
| 776 | 777 | is_utf8, | |
| 777 | 778 | msb_first, | |
| 779 | + | encoding_format, | |
| 778 | 780 | ) | |
| 779 | 781 | ||
| 780 | 782 | @property | |
The check that tells the two apart
fail→pass·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.