Commit d5b9f8d
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 8e13025 commit d5b9f8d
3 files changed
Lines changed: 89 additions & 3 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 | | |
| |||
111 | 112 | | |
112 | 113 | | |
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 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
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 | |
|---|---|---|---|
| |||
1702 | 1702 | | |
1703 | 1703 | | |
1704 | 1704 | | |
| 1705 | + | |
| 1706 | + | |
| 1707 | + | |
1705 | 1708 | | |
1706 | 1709 | | |
1707 | 1710 | | |
| 1711 | + | |
1708 | 1712 | | |
1709 | 1713 | | |
1710 | 1714 | | |
1711 | 1715 | | |
1712 | 1716 | | |
1713 | 1717 | | |
1714 | 1718 | | |
1715 | | - | |
| 1719 | + | |
| 1720 | + | |
1716 | 1721 | | |
| 1722 | + | |
| 1723 | + | |
1717 | 1724 | | |
1718 | 1725 | | |
1719 | 1726 | | |
1720 | 1727 | | |
1721 | 1728 | | |
1722 | 1729 | | |
| 1730 | + | |
| 1731 | + | |
| 1732 | + | |
| 1733 | + | |
1723 | 1734 | | |
1724 | 1735 | | |
1725 | | - | |
| 1736 | + | |
| 1737 | + | |
| 1738 | + | |
1726 | 1739 | | |
| 1740 | + | |
| 1741 | + | |
| 1742 | + | |
1727 | 1743 | | |
1728 | 1744 | | |
1729 | 1745 | | |
| |||
1800 | 1816 | | |
1801 | 1817 | | |
1802 | 1818 | | |
| 1819 | + | |
| 1820 | + | |
| 1821 | + | |
1803 | 1822 | | |
1804 | | - | |
| 1823 | + | |
| 1824 | + | |
1805 | 1825 | | |
| 1826 | + | |
1806 | 1827 | | |
1807 | 1828 | | |
1808 | 1829 | | |
| 1830 | + | |
1809 | 1831 | | |
1810 | 1832 | | |
| 1833 | + | |
1811 | 1834 | | |
1812 | 1835 | | |
1813 | 1836 | | |
| |||
0 commit comments