Commit c6d938e
authored
[mypyc] Fix b64decode to match new cpython behavior (#21200)
Fixes #21120
Behavior of `base64.b64decode` was recently [fixed in
cpython](python/cpython#145264) to no longer
stop processing the input data after the first padded quad. This
resulted in a failure in one of our tests as the result of the librt
implementation was no longer the same.
Update the librt implementation to match the new correct behavior.
Inputs where there are valid base64 characters after padding are
rejected by `libbase64` so we fall back to the slow path where we
preprocess the input. Currently this preprocessing matches the buggy
behavior where we stop processing after the first padded quad. Change
this to instead ignore padding in the middle of input, and only copy
padding at the end.
Behavior of librt will now be correct regardless of python version at
runtime as it doesn't seem worthwhile to preserve the buggy behavior for
compatibility. So modify the test to only perform checks on input where
there's data after padding with the python versions that have the
bugfix.1 parent a399e1c commit c6d938e
2 files changed
Lines changed: 29 additions & 31 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
243 | | - | |
| 243 | + | |
| 244 | + | |
244 | 245 | | |
245 | 246 | | |
246 | 247 | | |
247 | 248 | | |
| 249 | + | |
248 | 250 | | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
| 251 | + | |
271 | 252 | | |
272 | 253 | | |
273 | 254 | | |
| 255 | + | |
274 | 256 | | |
275 | | - | |
| 257 | + | |
276 | 258 | | |
277 | 259 | | |
278 | 260 | | |
| |||
282 | 264 | | |
283 | 265 | | |
284 | 266 | | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
285 | 276 | | |
286 | 277 | | |
287 | 278 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
121 | 122 | | |
122 | 123 | | |
123 | 124 | | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
124 | 133 | | |
125 | 134 | | |
126 | 135 | | |
| |||
135 | 144 | | |
136 | 145 | | |
137 | 146 | | |
138 | | - | |
139 | | - | |
140 | | - | |
| 147 | + | |
141 | 148 | | |
142 | 149 | | |
143 | 150 | | |
| |||
146 | 153 | | |
147 | 154 | | |
148 | 155 | | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
153 | 160 | | |
154 | 161 | | |
155 | 162 | | |
| |||
0 commit comments