mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
complain when a class variable shadows a name in __slots__ (closes #12766)
This commit is contained in:
parent
51be6e0a0f
commit
c4085c8470
3 changed files with 17 additions and 0 deletions
|
@ -4253,6 +4253,14 @@ order (MRO) for bases """
|
|||
foo = Foo()
|
||||
str(foo)
|
||||
|
||||
def test_slot_shadows_class(self):
|
||||
with self.assertRaises(ValueError) as cm:
|
||||
class X:
|
||||
__slots__ = ["foo"]
|
||||
foo = None
|
||||
m = str(cm.exception)
|
||||
self.assertEqual("'foo' in __slots__ conflicts with class variable", m)
|
||||
|
||||
class DictProxyTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
class C(object):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue