diff options
author | Shantanu <12621235+hauntsaninja@users.noreply.github.com> | 2022-10-31 12:31:01 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-31 12:31:01 (GMT) |
commit | 29f98b46b77ee528477b9a7b335974b9682f7f14 (patch) | |
tree | b4c0b421d8c8412bd33bede75f41782b2a9fe250 /Lib/test/test_dataclasses.py | |
parent | 87b5fd9d9de11c68b9940d3a1dba902138129109 (diff) | |
download | cpython-29f98b46b77ee528477b9a7b335974b9682f7f14.zip cpython-29f98b46b77ee528477b9a7b335974b9682f7f14.tar.gz cpython-29f98b46b77ee528477b9a7b335974b9682f7f14.tar.bz2 |
gh-96151: Use a private name for passing builtins to dataclass. This now allows for a field named BUILTIN (gh-98143)
Diffstat (limited to 'Lib/test/test_dataclasses.py')
-rw-r--r-- | Lib/test/test_dataclasses.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_dataclasses.py b/Lib/test/test_dataclasses.py index 637c456..01e6684 100644 --- a/Lib/test/test_dataclasses.py +++ b/Lib/test/test_dataclasses.py @@ -257,6 +257,14 @@ class TestCase(unittest.TestCase): c = C('foo') self.assertEqual(c.object, 'foo') + def test_field_named_BUILTINS_frozen(self): + # gh-96151 + @dataclass(frozen=True) + class C: + BUILTINS: int + c = C(5) + self.assertEqual(c.BUILTINS, 5) + def test_field_named_like_builtin(self): # Attribute names can shadow built-in names # since code generation is used. |