[Python-checkins] CVS: python/dist/src/Lib inspect.py,1.22,1.23

Tim Peters tim_one@users.sourceforge.net
Wed, 19 Sep 2001 22:47:57 -0700


Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv27494/python/Lib

Modified Files:
	inspect.py 
Log Message:
Ensure that isfunction(obj) and (the new) ismethoddescriptor(obj) never
both return true.  This restores pydoc's ability to deduce argument lists
for functions and methods coded in Python.


Index: inspect.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/inspect.py,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** inspect.py	2001/09/20 05:13:38	1.22
--- inspect.py	2001/09/20 05:47:55	1.23
***************
*** 59,63 ****
  
  def ismethoddescriptor(object):
!     """Return true if the object is a method descriptor, and ismethod false.
  
      This is new in Python 2.2, and, for example, is true of int.__add__.
--- 59,65 ----
  
  def ismethoddescriptor(object):
!     """Return true if the object is a method descriptor.
! 
!     But not if ismethod() or isclass() or isfunction() are true.
  
      This is new in Python 2.2, and, for example, is true of int.__add__.
***************
*** 66,76 ****
      usually sensible, and __doc__ often is.
  
!     Methods implemented via descriptors that also pass the ismethod() test
!     return false from the ismethoddescriptor() test, simply because
!     ismethod() is more informative -- you can, e.g., count on having the
!     im_func attribute (etc) when an object passes the latter."""
      return (hasattr(object, "__get__")
              and not hasattr(object, "__set__") # else it's a data descriptor
              and not ismethod(object)           # mutual exclusion
              and not isclass(object))
  
--- 68,79 ----
      usually sensible, and __doc__ often is.
  
!     Methods implemented via descriptors that also pass one of the other
!     tests return false from the ismethoddescriptor() test, simply because
!     the other tests promise more -- you can, e.g., count on having the
!     im_func attribute (etc) when an object passes ismethod()."""
      return (hasattr(object, "__get__")
              and not hasattr(object, "__set__") # else it's a data descriptor
              and not ismethod(object)           # mutual exclusion
+             and not isfunction(object)
              and not isclass(object))