The base64_codec incremental decoder decoded every chunk on its own, so splitting the input inside a group of four base64 characters failed:
>>> b"".join(codecs.iterdecode([b"AA", b"AA\r\n"], "base64"))
binascii.Error: Incorrect padding
It now subclasses codecs.BufferedIncrementalDecoder and decodes only complete groups of four alphabet characters, keeping the rest until the next call (or final=True). Bytes outside the alphabet (newlines, =) are not counted, since binascii.a2b_base64() ignores them in non-strict mode, so the joined output matches decoding the whole input at once.
The bz2_codec incremental decoder returned '' (a str) when called after the end of the compressed data; it now returns b''.
Martin Panter attached a patch to the original bpo issue in 2016. This is a new implementation against current main: that patch counted = as a data character, which no longer matches a2b_base64() (b"AA=AA=" decodes, but its first four characters b"AA=A" don't).
I used Claude Code to write this change.