diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-10-31 14:59:00 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-31 14:59:00 (GMT) |
commit | ca24e496bad2fcae0994b0de583f9cedc85bbd80 (patch) | |
tree | 55667557389aaf1f49a0cc94b43ac2ad46fecf4e /Lib/test/test_dataclasses.py | |
parent | 57dd11038f22379770d9f16e527f787fdea978fd (diff) | |
download | cpython-ca24e496bad2fcae0994b0de583f9cedc85bbd80.zip cpython-ca24e496bad2fcae0994b0de583f9cedc85bbd80.tar.gz cpython-ca24e496bad2fcae0994b0de583f9cedc85bbd80.tar.bz2 |
[3.11] gh-96151: Use a private name for passing builtins to dataclass. This now allows for a field named BUILTIN (gh-98143) (gh-98900)
gh-96151: Use a private name for passing builtins to dataclass. This now allows for a field named BUILTIN (gh-98143)
(cherry picked from commit 29f98b46b77ee528477b9a7b335974b9682f7f14)
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
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 63380ea..0d809bd 100644 --- a/Lib/test/test_dataclasses.py +++ b/Lib/test/test_dataclasses.py @@ -231,6 +231,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. |