Commit 6c9db0d
committed
binascii.c: Modify exception behavior on invalid encoded length
When decoding invalid length (1, 3 or 6 mod 8) + no padding,
mention the invalid length instead of the improper padding in
the exception message to match what the base64 decoder does.
Additionally, move the logic for setting the exception message
(back) outside the "slow path" loop; if we do end up checking
canonicity of decoder input, it will feel (subjectively) better
to have several checks grouped together after the loop.1 parent e3ee6df commit 6c9db0d
2 files changed
+25
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
782 | 782 | | |
783 | 783 | | |
784 | 784 | | |
785 | | - | |
786 | 785 | | |
787 | | - | |
788 | 786 | | |
789 | 787 | | |
790 | | - | |
791 | 788 | | |
792 | 789 | | |
793 | 790 | | |
| |||
806 | 803 | | |
807 | 804 | | |
808 | 805 | | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
809 | 810 | | |
810 | 811 | | |
811 | 812 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1562 | 1562 | | |
1563 | 1563 | | |
1564 | 1564 | | |
1565 | | - | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
1566 | 1569 | | |
1567 | 1570 | | |
1568 | | - | |
1569 | | - | |
1570 | | - | |
1571 | | - | |
1572 | | - | |
1573 | | - | |
1574 | | - | |
1575 | | - | |
1576 | | - | |
1577 | | - | |
1578 | | - | |
1579 | | - | |
1580 | | - | |
1581 | | - | |
1582 | | - | |
| 1571 | + | |
| 1572 | + | |
| 1573 | + | |
| 1574 | + | |
1583 | 1575 | | |
1584 | 1576 | | |
1585 | 1577 | | |
| |||
1644 | 1636 | | |
1645 | 1637 | | |
1646 | 1638 | | |
| 1639 | + | |
| 1640 | + | |
| 1641 | + | |
| 1642 | + | |
| 1643 | + | |
| 1644 | + | |
| 1645 | + | |
| 1646 | + | |
| 1647 | + | |
| 1648 | + | |
| 1649 | + | |
| 1650 | + | |
| 1651 | + | |
1647 | 1652 | | |
1648 | 1653 | | |
1649 | 1654 | | |
| |||
0 commit comments