Repository navigation
Commit cc51913
authored
Convert an
* Convert an index key before refusing item assignment
When a type has a sequence table but no ass_item slot, such as tuple,
bytes, str or any heap type, item assignment and deletion raised
TypeError without looking at the key. An index key is converted first,
so an exception from its __index__ propagates and an int too large for
an index raises IndexError. Only then is the operation refused.
Do that conversion in set_item() and del_item(). Deletion keeps the
"doesn't support" wording for index keys only, and uses "does not
support" for any other key.
Assisted-by: Claude Code:claude-opus-5-5
* Read the type name after converting the deletion key
del_item() held the read guard on a heap type's name while the key's
__index__ ran, so an __index__ that assigned the type's __name__
deadlocked a threaded build. Convert the key first and read the name
afterwards, which also names the renamed type as CPython does.
Keep the snippet's original docstring.
Assisted-by: Claude Code:claude-opus-5-5__index__ key before refusing item assignment or deletion (#9516)1 parent 860df6f commit cc51913
2 files changed
Lines changed: 77 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
18 | 32 | | |
19 | 33 | | |
20 | 34 | | |
| |||
812 | 826 | | |
813 | 827 | | |
814 | 828 | | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
815 | 833 | | |
816 | 834 | | |
817 | 835 | | |
| |||
836 | 854 | | |
837 | 855 | | |
838 | 856 | | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
839 | 860 | | |
840 | | - | |
| 861 | + | |
841 | 862 | | |
842 | 863 | | |
843 | 864 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
0 commit comments