One function
Bits in mahmoud/boltons
The author described this change as “Fix off-by-one in Bits length check”. It counts as a record because the check below fails on the code as it stood at e66cade32 and passes on c1c25da36, with nothing else changed between the two runs.
Projectmahmoud/boltons
Fix saved2026-08-06
Sharing licenceBSD-2-Clause · LICENSE
Change size+1 −1
What the code was meant to do, written into the code itself as a docstring
An immutable bit-string or bit-array object. Provides list-like access to bits as bools, as well as bitwise masking and shifting operators. Bits also make it easy to convert between many different useful representations: * bytes -- good for serializing raw binary data * int -- good for incrementing (e.g. to try all possible values) * list of bools -- good for iterating over or treating as flags * hex/bin string -- good for human readability
The change
| 38 | 38 | raise ValueError('Bits cannot represent negative values') | |
| 39 | 39 | if len_ is None: | |
| 40 | 40 | len_ = len(f'{val:b}') | |
| 41 | - | if val > 2 ** len_: | |
| 41 | + | if val >= 2 ** len_: | |
| 42 | 42 | raise ValueError(f'value {val} cannot be represented with {len_} bits') | |
| 43 | 43 | self.val = val # data is stored internally as integer | |
| 44 | 44 | self.len = len_ |
The check that tells the two apart
fail→pass·tests/test_mathutils.py::test_bits_len_bound
Check file tests/test_mathutils.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 ite66cade323f5c11cebb4bd0f099e634b245adccd
Broken version dated2026-07-18
Moduleboltons.mathutils
Units changedBits
Fingerprint8667d23e5a3e69d6
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 mahmoud/boltons
- 2026-08-06JSONLIterator
- 2026-08-06tableutils: fix Table.to_text crashes on degenerate tables and headers
- 2026-07-18backoff_iter
- 2026-07-17singularize
- 2026-07-17fix(fileutils): accept os.PathLike in AtomicSaver
- 2026-07-17Fix copy.copy/copy.deepcopy collapsing OrderedMultiDict values