Commit ff03e45
A reverse dict iterator only checked that the dict's size was unchanged,
so after the keys were replaced with the same number of keys it kept
yielding entries for the new keys. It could yield more items than the
dict had when it was created, and __length_hint__() then wrapped around.
Add the check the forward iterators already have: finding an entry after
the expected number of items raises "dictionary keys changed during
iteration".
(cherry picked from commit 042a7c1)
Co-authored-by: Joshua Bronson <jabronson@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 59c249e commit ff03e45
3 files changed
Lines changed: 34 additions & 0 deletions
File tree
- Lib/test
- Misc/NEWS.d/next/Core_and_Builtins
- Objects
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1517 | 1517 | | |
1518 | 1518 | | |
1519 | 1519 | | |
| 1520 | + | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
| 1532 | + | |
| 1533 | + | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
1520 | 1545 | | |
1521 | 1546 | | |
1522 | 1547 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5717 | 5717 | | |
5718 | 5718 | | |
5719 | 5719 | | |
| 5720 | + | |
| 5721 | + | |
| 5722 | + | |
| 5723 | + | |
| 5724 | + | |
| 5725 | + | |
5720 | 5726 | | |
5721 | 5727 | | |
5722 | 5728 | | |
| |||
0 commit comments