mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
gh-96151: Use a private name for passing builtins to dataclass. This now allows for a field named BUILTIN (gh-98143)
This commit is contained in:
parent
87b5fd9d9d
commit
29f98b46b7
3 changed files with 13 additions and 5 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue