10000 bpo-45897: Fix frozen-slotted dataclass bug by AlexWaygood · Pull Request #29895 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-45897: Fix frozen-slotted dataclass bug #29895

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 16 commits into from
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Tweak test
  • Loading branch information
AlexWaygood authored Dec 15, 2021
commit e968679ae4831bdf4841c8b9e701905375dde21f
16 changes: 10 additions & 6 deletions Lib/test/test_dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -2914,14 +2914,18 @@ class Point:
self.assertEqual(p.y, 2)
with self.assertRaises(FrozenInstanceError):
p.x = 2

try:
p.z = 5
except FrozenInstanceError as exc:
raise TypeError(
'FrozenInstanceError unexpectedly raised instead of AttributeError'
) from exc
except AttributeError:
pass
except Exception as exc:
exc_type = type(exc)
if exc_type is not AttributeError:
raise TypeError(
f'AttributeError was expected; got {exc_type.__name__!r} instead'
) from exc
else:
# Good! The test passes; AttributeError is what we want
pass
else:
self.fail('AttributeError expected, but no error was raised')

Expand Down
0