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

Ka-Ping Yee ping@users.sourceforge.net
Fri, 13 Apr 2001 02:15:10 -0700


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

Modified Files:
	inspect.py 
Log Message:
Remove duplicate type objects from isroutine() and isbuiltin().
Make getmodule() on a module return the module itself.


Index: inspect.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/inspect.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -r1.13 -r1.14
*** inspect.py	2001/04/12 13:17:17	1.13
--- inspect.py	2001/04/13 09:15:08	1.14
***************
*** 124,135 ****
          __name__        original name of this function or method
          __self__        instance to which a method is bound, or None"""
!     return type(object) in [types.BuiltinFunctionType,
!                             types.BuiltinMethodType]
  
  def isroutine(object):
      """Return true if the object is any kind of function or method."""
      return type(object) in [types.FunctionType, types.LambdaType,
!                             types.MethodType, types.BuiltinFunctionType,
!                             types.BuiltinMethodType]
  
  def getmembers(object, predicate=None):
--- 124,133 ----
          __name__        original name of this function or method
          __self__        instance to which a method is bound, or None"""
!     return type(object) is types.BuiltinFunctionType
  
  def isroutine(object):
      """Return true if the object is any kind of function or method."""
      return type(object) in [types.FunctionType, types.LambdaType,
!                             types.MethodType, types.BuiltinFunctionType]
  
  def getmembers(object, predicate=None):
***************
*** 232,235 ****
--- 230,235 ----
  def getmodule(object):
      """Return the module an object was defined in, or None if not found."""
+     if ismodule(object):
+         return object
      if isclass(object):
          return sys.modules.get(object.__module__)