mirror of
https://github.com/python/cpython.git
synced 2025-11-02 03:01:58 +00:00
Patch #1434038: property() now uses the getter's docstring if there is
no "doc" argument given. This makes it possible to legitimately use property() as a decorator to produce a read-only property.
This commit is contained in:
parent
f3c4ad1410
commit
533ff6fc06
4 changed files with 33 additions and 0 deletions
|
|
@ -2008,6 +2008,18 @@ def properties():
|
|||
else:
|
||||
raise TestFailed, "expected ZeroDivisionError from bad property"
|
||||
|
||||
class E(object):
|
||||
def getter(self):
|
||||
"getter method"
|
||||
return 0
|
||||
def setter(self, value):
|
||||
"setter method"
|
||||
pass
|
||||
prop = property(getter)
|
||||
vereq(prop.__doc__, "getter method")
|
||||
prop2 = property(fset=setter)
|
||||
vereq(prop2.__doc__, None)
|
||||
|
||||
def supers():
|
||||
if verbose: print "Testing super..."
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue