FIX: Ignore line breaks and spaces in Base64Decoder.write
PR
3d ago+19+19+01234567890123456789-1-1-0123456789
Fixes #340
Base64Decoder.write() sliced input to a multiple of 4 bytes while the data still contained \r, \n, space and tab. Line-wrapped base64 therefore failed with DecodeError whenever a quartet straddled a line break, and the outcome depended on chunk boundaries.
Changes
write()strips\r,\n, space and tab before counting and decoding. Other invalid bytes still raiseDecodeError, as before.write()now returns the number of bytes passed in. Previously it returned the length of the data after the internal cache was prepended, which does not match the docstring ("the length of the data to indicate no error").- Added
test_line_wrapped_input_any_split:base64.encodebytes()output split at every offset must decode to the original bytes, andwrite()must return the input length.
Testing
uv run pytest gives 164 passed. The new test fails on main without the change.