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.

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

6666 if _PY2: # pragma: no cover
6767 segment_data = [ord(b) for b in segment_data]
6868 # 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):
7070 code = (segment_data[i] << 8) | segment_data[i + 1]
7171 if 0xa1a1 <= code <= 0xaafe:
7272 # For characters with GB2312 values from A1A1HEX to AAFEHEX:
8686 # ISO/IEC 18004:2015(E) -- 7.4.6 Kanji mode (page 29)
8787 if _PY2: # pragma: no cover
8888 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):
9090 code = (segment_data[i] << 8) | segment_data[i + 1]
9191 if 0x8140 <= code <= 0x9ffc:
9292 # 1. a) For characters with Shift JIS values from 8140HEX to 9FFCHEX:

The check that tells the two apart

failpass·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.

Other bugs found in heuer/segno