One function
make_segment in heuer/segno
The author described this change as “FIX bug: use full length segment_data instead of half in Kanji/Hanzi mode”. It counts as a record because the check below fails on the code as it stood at 50914b3c4 and passes on 4a255ea88, with nothing else changed between the two runs.
Projectheuer/segno
Fix saved2020-07-30
Sharing licenceBSD-3-Clause · LICENSE
Change size+2 −2
What the code was meant to do, written into the code itself as a docstring
Creates a :py:class:`Segment`. :param data: The segment data :param mode: The mode. :param encoding: The encoding. :rtype: _Segment
The change
| 66 | 66 | if _PY2: # pragma: no cover | |
| 67 | 67 | segment_data = [ord(b) for b in segment_data] | |
| 68 | 68 | # Note: len(segment.data)! segment.data_length = len(segment.data) / 2!! | |
| 69 | - | for i in range(0, char_count, 2): | |
| 69 | + | for i in range(0, len(segment_data), 2): | |
| 70 | 70 | code = (segment_data[i] << 8) | segment_data[i + 1] | |
| 71 | 71 | if 0xa1a1 <= code <= 0xaafe: | |
| 72 | 72 | # For characters with GB2312 values from A1A1HEX to AAFEHEX: | |
| ⋯ | |||
| 86 | 86 | # ISO/IEC 18004:2015(E) -- 7.4.6 Kanji mode (page 29) | |
| 87 | 87 | if _PY2: # pragma: no cover | |
| 88 | 88 | segment_data = [ord(b) for b in segment_data] | |
| 89 | - | for i in range(0, char_count, 2): | |
| 89 | + | for i in range(0, len(segment_data), 2): | |
| 90 | 90 | code = (segment_data[i] << 8) | segment_data[i + 1] | |
| 91 | 91 | if 0x8140 <= code <= 0x9ffc: | |
| 92 | 92 | # 1. a) For characters with Shift JIS values from 8140HEX to 9FFCHEX: | |
The check that tells the two apart
fail→pass·tests/test_hanzi.py::test_force_hanzi_mode
Check file tests/test_hanzi.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 it50914b3c45c13671d5681acb75c5e809ab6ab2b9
Broken version dated2020-07-30
Modulesegno.encoder
Units changedmake_segment
Fingerprint3cc59612c04777fb
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.