One function

valid_base32 in algorand/pyteal

The author described this change as Fix base32 validation (#34). It counts as a record because the check below fails on the code as it stood at 2b064dccd and passes on 6ae118548, with nothing else changed between the two runs.

Fix saved2020-12-03
Sharing licenceMIT · LICENSE
Change size+3 2

What the code was meant to do, written into the code itself as a docstring

check if s is a valid base32 encoding string

The change

11 def valid_base32(s:str):
22 """ check if s is a valid base32 encoding string
33 """
4- pattern = re.compile(r'[A-Z2-9]*') # RFC 4648 base 32 w/o padding
4+ noPaddingPattern = re.compile(r'[A-Z2-7]*')
5+ paddingPattern = re.compile(r'^(?:[A-Z2-7]{8})*(?:([A-Z2-7]{8})|([A-Z2-7]{2}[=]{6})|([A-Z2-7]{4}[=]{4})|([A-Z2-7]{5}[=]{3})|([A-Z2-7]{7}[=]{1}))')
56
6- if pattern.fullmatch(s) is None:
7+ if noPaddingPattern.fullmatch(s) is None and paddingPattern.fullmatch(s) is None:
78 raise TealInputError("{} is not a valid RFC 4648 base 32 string".format(s))

The check that tells the two apart

failpass·pyteal/ast/bytes_test.py::test_bytes_base32_padding

Check file pyteal/ast/bytes_test.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 it2b064dccd24703faa01cf619e5a6b28b618c071a
Broken version dated2020-12-02
Modulepyteal.types
Units changedvalid_base32
Fingerprintdd8c05eb7c2c98b0
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.