mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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:
parent
27ec5bfdcb
commit
9ec07721f4
3 changed files with 31 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue