Commit f33ed21
User callbacks invoked during JSON encoding (e.g. the `default` callback or
a custom string encoder) can mutate or clear the dict or sequence being
encoded, invalidating borrowed references to items, keys, and values. Hold
strong references unconditionally while iterating.
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
(cherry picked from commit 235fa72)
1 parent 8ee6aff commit f33ed21
3 files changed
Lines changed: 91 additions & 4 deletions
File tree
- Lib/test/test_json
- Misc/NEWS.d/next/Library
- Modules
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1602 | 1602 | | |
1603 | 1603 | | |
1604 | 1604 | | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
1605 | 1608 | | |
1606 | 1609 | | |
1607 | 1610 | | |
| 1611 | + | |
1608 | 1612 | | |
1609 | 1613 | | |
1610 | 1614 | | |
1611 | 1615 | | |
1612 | 1616 | | |
1613 | 1617 | | |
1614 | 1618 | | |
1615 | | - | |
| 1619 | + | |
| 1620 | + | |
1616 | 1621 | | |
| 1622 | + | |
| 1623 | + | |
1617 | 1624 | | |
1618 | 1625 | | |
1619 | 1626 | | |
1620 | 1627 | | |
1621 | 1628 | | |
1622 | 1629 | | |
| 1630 | + | |
| 1631 | + | |
| 1632 | + | |
| 1633 | + | |
1623 | 1634 | | |
1624 | 1635 | | |
1625 | | - | |
| 1636 | + | |
| 1637 | + | |
| 1638 | + | |
1626 | 1639 | | |
| 1640 | + | |
| 1641 | + | |
| 1642 | + | |
1627 | 1643 | | |
1628 | 1644 | | |
1629 | 1645 | | |
| |||
1712 | 1728 | | |
1713 | 1729 | | |
1714 | 1730 | | |
| 1731 | + | |
| 1732 | + | |
| 1733 | + | |
1715 | 1734 | | |
1716 | | - | |
| 1735 | + | |
| 1736 | + | |
1717 | 1737 | | |
| 1738 | + | |
1718 | 1739 | | |
1719 | | - | |
| 1740 | + | |
| 1741 | + | |
1720 | 1742 | | |
| 1743 | + | |
| 1744 | + | |
1721 | 1745 | | |
1722 | 1746 | | |
1723 | 1747 | | |
| |||
0 commit comments