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
Switch frozen-instance error type from TypeError to dataclasses.FrozenInstanceError #102
Spun off from #35 (closed in 2.2.0): the immutability cleanup for unpythonic.llist.cons (and any future "frozen" types in this codebase) shipped raising TypeError to preserve API stability under the 2.x compatibility promise.
Standard library convention since Python 3.7 is dataclasses.FrozenInstanceError for "tried to mutate a frozen instance." Aligning is desirable for ecosystem consistency, but FrozenInstanceError subclasses AttributeError, notTypeError. Switching is therefore a breaking change for any user code catching TypeError from a cons mutation attempt — appropriate for a major-version bump.
Scope
unpythonic/llist.py: cons.__setattr__ and cons.__delattr__ raise dataclasses.FrozenInstanceError instead of TypeError.
Tests: update unpythonic/tests/test_llist.py immutability assertions to expect FrozenInstanceError (or AttributeError).
CHANGELOG: Changed (breaking) entry under 3.0.0.
Audit any other "frozen" types added between now and 3.0.0 for the same alignment.
Notes
assignonce.__delattr__ (added in 2.2.0) raises AttributeError, which already aligns naturally — leave alone.
frozendict does not currently lock down attribute writes (only mapping writes); this issue is about types whose contract is "frozen instance."
Update: shim approach landed in 2.2.0. unpythonic.llist.FrozenAttributeError multiply-inherits from TypeError and dataclasses.FrozenInstanceError; cons raises this. Either except TypeError or except FrozenInstanceError catches.
Scope of this issue therefore shifts:
3.0.0 work is now to drop the TypeError base from FrozenAttributeError (or replace usages with plain FrozenInstanceError and remove the shim class).
The compat-during-2.x problem is solved; this is a clean stdlib-alignment step for 3.0.0.
Activity
llist: cons __delattr__ + simplify via object.__setattr__
Technologicat commentedon May 6, 2026
Update: shim approach landed in 2.2.0.
unpythonic.llist.FrozenAttributeErrormultiply-inherits fromTypeErroranddataclasses.FrozenInstanceError;consraises this. Eitherexcept TypeErrororexcept FrozenInstanceErrorcatches.Scope of this issue therefore shifts:
TypeErrorbase fromFrozenAttributeError(or replace usages with plainFrozenInstanceErrorand remove the shim class).— Claude (Opus 4.7)
llist: FrozenAttributeError shim, raised by cons