This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Make property use the getter's __doc__ if no doc argument
Type: Stage:
Components: Interpreter Core Versions: Python 2.5
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: aleax, georg.brandl, georg.brandl, gvanrossum
Priority: normal Keywords: patch

Created on 2006-02-18 08:37 by georg.brandl, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit
property-get-doc.diff georg.brandl, 2006-02-18 18:51 descrobject patch v2
property-get-doc-2.diff georg.brandl, 2006-02-18 18:51 docs/tests patch v2
Messages (8)
msg49532 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-02-18 08:37
As requested by Guido in

The patch adds a check that fget, fset and fdel are
callable, if present.

Please check for ref leaks et al.
msg49533 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-02-18 09:51
Logged In: YES 

Adding docs and test suite changes.
msg49534 - (view) Author: Alex Martelli (aleax) * (Python committer) Date: 2006-02-18 15:21
Logged In: YES 

in property-get-doc.diff:

if doc is None and fget.__doc__ is not None:

would raise a confusing TypeError when doc is fget is None -- check for that 
case explicitly to raise a specific exception.  Also, property(fset=foo) used to 
work and thus must keep working.  Similarly, the C code

if ((get_doc = PyObject_GetAttrString(get, "__doc__")))

must reset the errorstate if get_doc is NULL.

in property-get-doc-2.diff:

Add unittest to check that property(fset=somecallable) keeps working.

msg49535 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-02-18 18:51
Logged In: YES 

Thanks for the review. Attaching new patches with your
corrections. I also added a DECREF which I think is necessary.
msg49536 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2006-02-19 20:08
Logged In: YES 

I'll try to review this ASAP.
msg49537 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-03-08 17:32
Logged In: YES 

msg49538 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2006-03-08 17:47
Logged In: YES 

Sorry, I really don't like the callable checks.  IMO they're
for wimps.  You should be testing your code anyway, and then
bad property args will show up the first time they are called.

Without those, I'm fine with the changes.  Discuss on
python-def if you disagree.
msg49539 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-03-08 18:10
Logged In: YES 

Fine with me too.

Committed patch without callable checks as revision 42916.
Date User Action Args
2022-04-11 14:56:15adminsetgithub: 42921
2006-02-18 08:37:50birkenfeldcreate