diff options
author | Benjamin Peterson <benjamin@python.org> | 2010-01-18 23:07:56 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2010-01-18 23:07:56 (GMT) |
commit | 9179dab3f4d5552e756c221830f7174cb9218b64 (patch) | |
tree | d04cf3783c93eb36433ada5f6a549157667d5458 /Lib/test/test_descr.py | |
parent | c07336c673a811afe3d675ffa257489ee86613ee (diff) | |
download | cpython-9179dab3f4d5552e756c221830f7174cb9218b64.zip cpython-9179dab3f4d5552e756c221830f7174cb9218b64.tar.gz cpython-9179dab3f4d5552e756c221830f7174cb9218b64.tar.bz2 |
data descriptors do not override the class dictionary if __get__ is not defined
Adjust documentation and add a test to verify this behavior.
See http://mail.python.org/pipermail/python-dev/2010-January/095637.html for
discussion.
Diffstat (limited to 'Lib/test/test_descr.py')
-rw-r--r-- | Lib/test/test_descr.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index 418337b..36af26c 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -4496,6 +4496,26 @@ order (MRO) for bases """ c[1:2] = 3 self.assertEqual(c.value, 3) + def test_set_and_no_get(self): + # See + # http://mail.python.org/pipermail/python-dev/2010-January/095637.html + class Descr(object): + + def __init__(self, name): + self.name = name + + def __set__(self, obj, value): + obj.__dict__[self.name] = value + descr = Descr("a") + + class X(object): + a = descr + + x = X() + self.assertIs(x.a, descr) + x.a = 42 + self.assertEqual(x.a, 42) + def test_getattr_hooks(self): # issue 4230 |