@@ -119,11 +119,12 @@ The :mod:`!binascii` module defines the following functions:
119119 Convert Ascii85 data back to binary and return the binary data.
120120
121121 Valid Ascii85 data contains characters from the Ascii85 alphabet in groups
122- of five (except for the final group, which may have from two to five
122+ of five (except for the final group, which may have from two to four
123123 characters). Each group encodes 32 bits of binary data in the range from
124124 ``0 `` to ``2 ** 32 - 1 ``, inclusive. The special character ``z `` is
125125 accepted as a short form of the group ``!!!!! ``, which encodes four
126- consecutive null bytes.
126+ consecutive null bytes. A single-character final group is always rejected
127+ as an encoding violation.
127128
128129 *foldspaces * is a flag that specifies whether the 'y' short sequence
129130 should be accepted as shorthand for 4 consecutive spaces (ASCII 0x20).
@@ -136,15 +137,20 @@ The :mod:`!binascii` module defines the following functions:
136137 to ignore from the input.
137138 This should only contain whitespace characters.
138139
139- If *canonical * is true, non-canonical encodings in the final group are
140- rejected with :exc: `binascii.Error `. This includes single-character
141- final groups (which no conforming encoder produces) and final groups whose
142- padding digits are not what the encoder would produce.
140+ If *canonical * is true, non-canonical encodings are rejected with
141+ :exc: `binascii.Error `. This enforces that the `` z `` abbreviation is used
142+ for all-zero groups (rather than `` !!!!! ``), and that partial final groups
143+ use the same padding digits the encoder would produce.
143144
144145 Invalid Ascii85 data will raise :exc: `binascii.Error `.
145146
146147 .. versionadded :: 3.15
147148
149+ .. versionchanged :: next
150+ Single-character final groups are now always rejected as encoding
151+ violations. Previously they were silently ignored, producing no output
152+ bytes.
153+
148154
149155.. function :: b2a_ascii85(data, /, *, foldspaces=False, wrapcol=0, pad=False, adobe=False)
150156
@@ -175,25 +181,30 @@ The :mod:`!binascii` module defines the following functions:
175181 More than one line may be passed at a time.
176182
177183 Valid Base85 data contains characters from the Base85 alphabet in groups
178- of five (except for the final group, which may have from two to five
184+ of five (except for the final group, which may have from two to four
179185 characters). Each group encodes 32 bits of binary data in the range from
180- ``0 `` to ``2 ** 32 - 1 ``, inclusive.
186+ ``0 `` to ``2 ** 32 - 1 ``, inclusive. A single-character final group is
187+ always rejected as an encoding violation.
181188
182189 Optional *alphabet * must be a :class: `bytes ` object of length 85 which
183190 specifies an alternative alphabet.
184191
185192 *ignorechars * should be a :term: `bytes-like object ` containing characters
186193 to ignore from the input.
187194
188- If *canonical * is true, non-canonical encodings in the final group are
189- rejected with :exc: `binascii.Error `. This includes single-character
190- final groups (which no conforming encoder produces) and final groups whose
191- padding digits are not what the encoder would produce.
195+ If *canonical * is true, non-canonical encodings in partial final groups
196+ are rejected with :exc: `binascii.Error `. This enforces that the padding
197+ digits match what the encoder would produce.
192198
193199 Invalid Base85 data will raise :exc: `binascii.Error `.
194200
195201 .. versionadded :: 3.15
196202
203+ .. versionchanged :: next
204+ Single-character final groups are now always rejected as encoding
205+ violations. Previously they were silently ignored, producing no output
206+ bytes.
207+
197208
198209.. function :: b2a_base85(data, /, *, alphabet=BASE85_ALPHABET, wrapcol=0, pad=False)
199210
0 commit comments