You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit df1c7c1
Browse filesBrowse the repository at this point in the historyBrowse files
fix: make ComponentRegistry.register() additive; track finalizers per name
`register()` now treats re-registration strictly:
- Same class object under same name -> no-op (covers the common autodiscover-
runs-twice case, since `@register` decorators only re-run when their module
is actually re-executed).
- Any other class under an existing name -> raise `AlreadyRegistered`. Callers
that intentionally replace a registration (hot-reload scripts, settings
re-application) must `unregister()` first. The new exception message says so.
The old loose behavior - silent overwrite whenever `class_id` collided - was
the trapdoor #1598 went through. With strict registration plus the
sys.modules snapshot landed in the previous commit, the only way to reach
the "different object under same name" branch is an explicit reimport,
which is always intentional.
Track the `weakref.finalize` handle per registered name in `_finalizers` so
`unregister()` can `.detach()` it eagerly. This makes the registry state
deterministic regardless of GC timing, and turns #1630's id-check-at-fire-
time defense into pure defense-in-depth.
Strengthen `@djc_test` teardown to restore each registry's initial entries
(not just remove what was added). Necessary because the strict contract
forces tests that re-init a registration to `unregister` + `register`
rather than rely on silent overwrite; without restoration, those removals
leaked into later tests.
Update three tests that relied on the old loose behavior to call
`unregister()` explicitly before re-registering.
0 commit comments