| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1248,6 +1248,15 @@ def test_sort(self, size): | |||
| 1248 | 1248 | self.assertEqual(l[-10:], [5] * 10) | |
| 1249 | 1249 | ||
| 1250 | 1250 | ||
| 1251 | + class DictTest(unittest.TestCase): | ||
| 1252 | + | ||
| 1253 | + @bigmemtest(size=357913941, memuse=160) | ||
| 1254 | + def test_dict(self, size): | ||
| 1255 | + # https://github.com/python/cpython/issues/102701 | ||
| 1256 | + d = dict.fromkeys(range(size)) | ||
| 1257 | + d[size] = 1 | ||
| 1258 | + | ||
| 1259 | + | ||
| 1251 | 1260 | if __name__ == '__main__': | |
| 1252 | 1261 | if len(sys.argv) > 1: | |
| 1253 | 1262 | support.set_memlimit(sys.argv[1]) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1 @@ | |||
| 1 | + Fix overflow when creating very large dict. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -596,7 +596,7 @@ new_keys_object(PyInterpreterState *interp, uint8_t log2_size, bool unicode) | |||
| 596 | 596 | ||
| 597 | 597 | assert(log2_size >= PyDict_LOG_MINSIZE); | |
| 598 | 598 | ||
| 599 | - usable = USABLE_FRACTION(1<<log2_size); | ||
| 599 | + usable = USABLE_FRACTION((size_t)1<<log2_size); | ||
| 600 | 600 | if (log2_size < 8) { | |
| 601 | 601 | log2_bytes = log2_size; | |
| 602 | 602 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments