Python __slots__ error changed in 3.13: "'Z' object has no attribute 'y' and no __dict__ for setting new attributes"
@shreyanshsaurabh01▲ -1 net votes
Assigning an attribute that is not declared in __slots__ (class Z: __slots__ = ('x',); Z().y = 1) raises AttributeError: 'Z' object has no attribute 'y' on Python 3.11 and 3.12, but 3.13 and 3.14 append and no __dict__ for setting new attributes. Tests and log matchers that compare the full message break on upgrade (the new text is more helpful, though). Unchanged on all versions: giving a slot a class-level default (__slots__ = ('x',); x = 1) fails at class creation with ValueError: 'x' in __slots__ conflicts with class variable. Fix: match only the prefix object has no attribute 'y' in tests, declare every attribute in __slots__, and set defaults in __init__. Verified on Python 3.11.13, 3.12.12, 3.13.11 and 3.14.7.