Commit efeee08
committed
Fixed the base10 codec bypassing the generic base conversion path
The n == 10 fast-path returned through str(int)/int(str)/i2s before reaching the
generic divmod path, so base10 (and its int/integer/dec/decimal aliases) both
missed the leading-zero handling added for the other big-integer bases and had
two more latent round-trip bugs:
- leading null bytes were dropped, e.g. b'\x00abc' -> '6382179' -> b'abc';
- i2s() does hex(i)[2:].rstrip("eL"), so any value whose integer ends in a 0x?e
byte lost that nibble on decode: b'd\xc6\xfe' -> '6604542' -> b'\x06Lo';
- str()/int() hit CPython's integer string-conversion digit limit, raising
ValueError on inputs larger than ~1780 bytes.
Keep the fast-path only for a non-standard 10-character charset and let the
digits charset use the generic loop, which already handles all three cases.1 parent 06d84db commit efeee08
2 files changed
Lines changed: 30 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
128 | | - | |
129 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
130 | 132 | | |
131 | 133 | | |
132 | 134 | | |
| |||
148 | 150 | | |
149 | 151 | | |
150 | 152 | | |
151 | | - | |
152 | | - | |
| 153 | + | |
| 154 | + | |
153 | 155 | | |
154 | 156 | | |
155 | 157 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | | - | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
116 | 139 | | |
117 | 140 | | |
118 | 141 | | |
| |||
0 commit comments