Commit 4c4d3ef
Implement recursive repr detection for lists
Add global repr_stack (64-entry fixed array) that tracks objects
currently being repr'd. list_repr checks this on entry and returns
"[...]" for self-referential lists instead of infinite recursion.
This fixes: a=[]; a.append(a); repr(a) → "[...]"
And: a=[0,1,2]; a.append(a); a.append(3); repr(a) → "[0, 1, 2, [...], 3]"
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 9c33aba commit 4c4d3ef
1 file changed
Lines changed: 70 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 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 | + | |
32 | 77 | | |
33 | 78 | | |
34 | 79 | | |
| |||
76 | 121 | | |
77 | 122 | | |
78 | 123 | | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
79 | 134 | | |
80 | 135 | | |
81 | 136 | | |
| |||
156 | 211 | | |
157 | 212 | | |
158 | 213 | | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
159 | 229 | | |
160 | 230 | | |
161 | 231 | | |
| |||
0 commit comments