cpython: 1e8a768fa0a5 (original) (raw)

Mercurial > cpython

changeset 96010:1e8a768fa0a5

Issue #24064: Property() docstrings are now writeable. (Patch by Berker Peksag.) [#24064]

Raymond Hettinger python@rcn.com
date Wed, 13 May 2015 01:09:59 -0700
parents 4cf37a50d91a
children 79c884cc9625
files Doc/library/collections.rst Doc/whatsnew/3.5.rst Lib/test/test_collections.py Lib/test/test_descr.py Lib/test/test_property.py Misc/NEWS Objects/descrobject.c
diffstat 7 files changed, 63 insertions(+), 2 deletions(-)[+] [-] Doc/library/collections.rst 9 Doc/whatsnew/3.5.rst 16 Lib/test/test_collections.py 8 Lib/test/test_descr.py 5 Lib/test/test_property.py 22 Misc/NEWS 3 Objects/descrobject.c 2

line wrap: on

line diff

--- a/Doc/library/collections.rst +++ b/Doc/library/collections.rst @@ -924,6 +924,15 @@ create a new named tuple type from the : >>> Point3D = namedtuple('Point3D', Point._fields + ('z',)) +Docstrings can be customized by making direct assignments to the __doc__ +fields: +

Default values can be implemented by using :meth:_replace to customize a prototype instance:

--- a/Doc/whatsnew/3.5.rst +++ b/Doc/whatsnew/3.5.rst @@ -234,6 +234,10 @@ Some smaller changes made to the core Py

+

--- a/Lib/test/test_collections.py +++ b/Lib/test/test_collections.py @@ -199,6 +199,14 @@ class TestNamedTuple(unittest.TestCase): Point = namedtuple('Point', 'x y') self.assertEqual(Point.doc, 'Point(x, y)')

+ def test_name_fixer(self): for spec, renamed in [ [('efg', 'g%hi'), ('efg', '_1')], # field with non-alpha char

--- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -2022,7 +2022,7 @@ order (MRO) for bases """ self.assertIs(raw.fset, C.dict['setx']) self.assertIs(raw.fdel, C.dict['delx'])

@@ -2033,6 +2033,9 @@ order (MRO) for bases """ self.fail("expected AttributeError from trying to set readonly %r " "attr on a property" % attr)

+ class D(object): getitem = property(lambda s: 1/0)

--- a/Lib/test/test_property.py +++ b/Lib/test/test_property.py @@ -76,6 +76,13 @@ class PropertyNewGetter(object): """new docstring""" return 8 +class PropertyWritableDoc(object): +

+ class PropertyTests(unittest.TestCase): def test_property_decorator_baseclass(self): # see #1620 @@ -150,6 +157,21 @@ class PropertyTests(unittest.TestCase): foo = property(foo) C.foo.isabstractmethod

+

Issue 5890: subclasses of property do not preserve method doc strings

class PropertySub(property):

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -45,6 +45,9 @@ Library

--- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1313,7 +1313,7 @@ static PyMemberDef property_members[] = {"fget", T_OBJECT, offsetof(propertyobject, prop_get), READONLY}, {"fset", T_OBJECT, offsetof(propertyobject, prop_set), READONLY}, {"fdel", T_OBJECT, offsetof(propertyobject, prop_del), READONLY},