diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-11-29 07:54:17 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-11-29 07:54:17 (GMT) |
commit | 9ec07721f459d14131d6453ccb6d2a1a0b0c1959 (patch) | |
tree | ed40463ef4cdc4a7beb4142860dafddf48105692 /Lib/test/test_subclassinit.py | |
parent | 27ec5bfdcbc646c0598834e7500790f0938c5557 (diff) | |
download | cpython-9ec07721f459d14131d6453ccb6d2a1a0b0c1959.zip cpython-9ec07721f459d14131d6453ccb6d2a1a0b0c1959.tar.gz cpython-9ec07721f459d14131d6453ccb6d2a1a0b0c1959.tar.bz2 |
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.
Diffstat (limited to 'Lib/test/test_subclassinit.py')
-rw-r--r-- | Lib/test/test_subclassinit.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_subclassinit.py b/Lib/test/test_subclassinit.py index 6a12fb1..3c331bb9 100644 --- a/Lib/test/test_subclassinit.py +++ b/Lib/test/test_subclassinit.py @@ -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 |