Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Lib/test/test_dataclasses/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3404,6 +3404,14 @@ class C:

c = C('hello')
self.assertEqual(deepcopy(c), c)
def test_frozen_slots_setattr(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def test_frozen_slots_setattr(self):
def test_frozen_slots_setattr(self):

# gh-143969: Ensure frozen+slots uses object.__setattr__
@dataclass(frozen=True, slots=True)
class A:
x: int
a = A(1)
with self.assertRaisesRegex(FrozenInstanceError, 'cannot assign to field'):
a.x = 2


class TestSlots(unittest.TestCase):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fixed a crash in frozen slotted dataclasses where assigning to an attribute
could raise an internal TypeError instead of failing cleanly.
Loading