Commit 177778e
committed
Reject bool under explicit INTEGER and report UTF-8 byte offset on NUL
Two small encoder hygiene changes:
- encode_value now rejects bool when the caller passes an explicit
ValueType.INTEGER (or UNIXTIME), matching the FLOAT branch which
already rejects bool. Previously INTEGER silently coerced
True/False to 1/0, producing the round-trip surprise "True bound
as INTEGER decodes as 1 (int), not True (bool)". The default-
inference path still picks BOOLEAN for bools, so callers that
want integer semantics must cast via int(x) explicitly —
consistent with "explicit over implicit".
- encode_text's embedded-NUL error now reports the UTF-8 byte
offset rather than the Python code-point index. For pure-ASCII
strings the two agree; for strings containing multi-byte
codepoints (e.g. "café\\x00" — 4 codepoints, 5 UTF-8 bytes, NUL
at byte 5 / codepoint 4) the byte offset matches wire captures
and hex-editor output that an operator would use to debug. The
"embedded null byte" match string is preserved so existing tests
pass unchanged.1 parent 51f7850 commit 177778e
2 files changed
Lines changed: 53 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | 134 | | |
140 | | - | |
| 135 | + | |
141 | 136 | | |
142 | 137 | | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
143 | 148 | | |
144 | 149 | | |
145 | 150 | | |
| |||
308 | 313 | | |
309 | 314 | | |
310 | 315 | | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
311 | 323 | | |
312 | | - | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
313 | 328 | | |
314 | 329 | | |
315 | 330 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
264 | 264 | | |
265 | 265 | | |
266 | 266 | | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
267 | 277 | | |
268 | 278 | | |
269 | 279 | | |
| |||
747 | 757 | | |
748 | 758 | | |
749 | 759 | | |
750 | | - | |
751 | | - | |
752 | | - | |
753 | | - | |
754 | | - | |
755 | | - | |
756 | | - | |
757 | | - | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
758 | 780 | | |
759 | | - | |
| 781 | + | |
760 | 782 | | |
761 | 783 | | |
762 | 784 | | |
| |||
0 commit comments