[Python-checkins] python/dist/src/Lib inspect.py,1.42,1.43 pydoc.py,1.81,1.82
loewis@users.sourceforge.net
loewis@users.sourceforge.net
Sat, 03 May 2003 02:09:04 -0700
Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1:/tmp/cvs-serv17854/Lib
Modified Files:
inspect.py pydoc.py
Log Message:
Patch #711902: Cause pydoc to show data descriptor __doc__ strings.
Index: inspect.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/inspect.py,v
retrieving revision 1.42
retrieving revision 1.43
diff -C2 -d -r1.42 -r1.43
*** inspect.py 28 Mar 2003 16:29:50 -0000 1.42
--- inspect.py 3 May 2003 09:09:01 -0000 1.43
***************
*** 79,82 ****
--- 79,92 ----
and not isclass(object))
+ def isdatadescriptor(object):
+ """Return true if the object is a data descriptor.
+
+ Data descriptors have both a __get__ and a __set__ attribute. Examples are
+ properties (defined in Python) and getsets and members (defined in C).
+ Typically, data descriptors will also have __name__ and __doc__ attributes
+ (properties, getsets, and members have both of these attributes), but this
+ is not guaranteed."""
+ return (hasattr(object, "__set__") and hasattr(object, "__get__"))
+
def isfunction(object):
"""Return true if the object is a user-defined function.
Index: pydoc.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/pydoc.py,v
retrieving revision 1.81
retrieving revision 1.82
diff -C2 -d -r1.81 -r1.82
*** pydoc.py 30 Mar 2003 20:31:34 -0000 1.81
--- pydoc.py 3 May 2003 09:09:01 -0000 1.82
***************
*** 687,691 ****
for name, kind, homecls, value in ok:
base = self.docother(getattr(object, name), name, mod)
! if callable(value):
doc = getattr(value, "__doc__", None)
else:
--- 687,691 ----
for name, kind, homecls, value in ok:
base = self.docother(getattr(object, name), name, mod)
! if callable(value) or inspect.isdatadescriptor(value):
doc = getattr(value, "__doc__", None)
else:
***************
*** 1088,1092 ****
push(msg)
for name, kind, homecls, value in ok:
! if callable(value):
doc = getattr(value, "__doc__", None)
else:
--- 1088,1092 ----
push(msg)
for name, kind, homecls, value in ok:
! if callable(value) or inspect.isdatadescriptor(value):
doc = getattr(value, "__doc__", None)
else: