Issue #28797: Modifying the class __dict__ inside the __set_name__ method of

a descriptor that is used inside that class no longer prevents calling the
 __set_name__ method of other descriptors.
This commit is contained in:
Serhiy Storchaka 2016-11-29 09:54:17 +02:00
parent 27ec5bfdcb
commit 9ec07721f4
3 changed files with 31 additions and 3 deletions

View file

@ -198,6 +198,22 @@ class Test(unittest.TestCase):
self.assertIs(B.meta_owner, B)
self.assertEqual(B.name, 'd')
def test_set_name_modifying_dict(self):
notified = []
class Descriptor:
def __set_name__(self, owner, name):
setattr(owner, name + 'x', None)
notified.append(name)
class A:
a = Descriptor()
b = Descriptor()
c = Descriptor()
d = Descriptor()
e = Descriptor()
self.assertCountEqual(notified, ['a', 'b', 'c', 'd', 'e'])
def test_errors(self):
class MyMeta(type):
pass