One function
string_to_int in skorokithakis/shortuuid
The author described this change as “fix: Fix string_to_int radix when alphabet_index is provided (#115)”. It counts as a record because the check below fails on the code as it stood at b8898871c and passes on 496cddf18, with nothing else changed between the two runs.
Projectskorokithakis/shortuuid
Fix saved2026-06-18
Sharing licenceBSD-3-Clause · COPYING
Change size+3 −1
What the code was meant to do, written into the code itself as a docstring
Convert a string to a number, using the given alphabet. The input is assumed to have the most significant digit first. The alphabet_index, if provided, should map each character to its index: `{char: idx for idx, char in enumerate(alphabet)}`. This avoids rebuilding the index on each call when decoding multiple strings with the same alphabet. If this is passed, `alphabet` is ignored.
The change
| 16 | 16 | if alphabet_index is None: | |
| 17 | 17 | alphabet_index = {char: idx for idx, char in enumerate(alphabet)} | |
| 18 | 18 | number = 0 | |
| 19 | - | alpha_len = len(alphabet) | |
| 19 | + | # Derive the radix from the index so `alphabet` is truly ignored when | |
| 20 | + | # alphabet_index is passed, as documented above. | |
| 21 | + | alpha_len = len(alphabet_index) | |
| 20 | 22 | for char in string: | |
| 21 | 23 | try: | |
| 22 | 24 | number = number * alpha_len + alphabet_index[char] |
The check that tells the two apart
fail→pass·shortuuid/test_shortuuid.py::DecodingEdgeCasesTest::test_string_to_int_ignores_alphabet_when_index_given
Check file shortuuid/test_shortuuid.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 itb8898871c5b977549b4ecbecbb638d8e06d7359e
Broken version dated2025-12-01
Moduleshortuuid.main
Units changedstring_to_int
Fingerprintc44f3acf6ebcf1cc
Checked2026-08-17 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.