Repository navigation
Commit 1d933cb
committed
fix: move ComponentNode subclass cache from module global to per registry
`component_node_subclasses_by_name` was a module-global dict keyed by
`start_tag`, storing `(subcls, registry)` tuples. The tuple held strong
references to both the subclass and the registry; the dict held the
tuple; the only thing that would remove the entry was either of two
`finalize` callbacks. Since the tuple kept both targets reachable, the
finalizers could never fire and the cache pinned both forever - dead
code in CPython, and the same `start_tag` collision pattern as #1598
waiting to surface if the cycle ever broke.
Move the cache to `ComponentRegistry._node_subcls_cache`. Lifetime
follows the registry: when the registry goes away, so does its cache.
Cross-registry collisions are now structurally impossible (each registry
has its own cache), so the `cached_registry is not registry` RuntimeError
is dropped. The intra-registry "different end_tag for same start_tag"
RuntimeError stays - it still catches tag-formatter inconsistency.
`@djc_test` teardown now clears each surviving registry's cache, so a
follow-up test using a different `tag_formatter` for the same start_tag
isn't tripped by a leftover entry.1 parent df1c7c1 commit 1d933cb
4 files changed
Lines changed: 61 additions & 30 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3457 | 3457 | | |
3458 | 3458 | | |
3459 | 3459 | | |
3460 | | - | |
3461 | | - | |
3462 | | - | |
3463 | | - | |
3464 | | - | |
3465 | | - | |
3466 | | - | |
3467 | | - | |
3468 | 3460 | | |
3469 | 3461 | | |
3470 | 3462 | | |
| |||
3608 | 3600 | | |
3609 | 3601 | | |
3610 | 3602 | | |
3611 | | - | |
3612 | | - | |
3613 | | - | |
3614 | | - | |
3615 | | - | |
3616 | | - | |
3617 | | - | |
3618 | | - | |
3619 | | - | |
3620 | | - | |
3621 | | - | |
3622 | | - | |
3623 | | - | |
3624 | | - | |
3625 | | - | |
3626 | | - | |
3627 | | - | |
| 3603 | + | |
| 3604 | + | |
| 3605 | + | |
| 3606 | + | |
| 3607 | + | |
| 3608 | + | |
| 3609 | + | |
| 3610 | + | |
| 3611 | + | |
| 3612 | + | |
3628 | 3613 | | |
3629 | 3614 | | |
3630 | 3615 | | |
| |||
3633 | 3618 | | |
3634 | 3619 | | |
3635 | 3620 | | |
3636 | | - | |
| 3621 | + | |
3637 | 3622 | | |
3638 | 3623 | | |
3639 | 3624 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
244 | 244 | | |
245 | 245 | | |
246 | 246 | | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
247 | 252 | | |
248 | 253 | | |
249 | 254 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
494 | 494 | | |
495 | 495 | | |
496 | 496 | | |
497 | | - | |
498 | | - | |
499 | | - | |
500 | 497 | | |
501 | 498 | | |
502 | 499 | | |
| |||
556 | 553 | | |
557 | 554 | | |
558 | 555 | | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
559 | 562 | | |
560 | 563 | | |
561 | 564 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
193 | 231 | | |
194 | 232 | | |
195 | 233 | | |
| |||
0 commit comments