diff options
author | Ka-Ping Yee <ping@zesty.ca> | 2001-04-13 09:15:08 (GMT) |
---|---|---|
committer | Ka-Ping Yee <ping@zesty.ca> | 2001-04-13 09:15:08 (GMT) |
commit | 202c99b2e0242a5680668816a65051a1f1aef8ed (patch) | |
tree | e712d65a87facc0cd74abae2d599464538a69cda /Lib/inspect.py | |
parent | 88ad12afacb2b08b5d675be61f47c9244fba6825 (diff) | |
download | cpython-202c99b2e0242a5680668816a65051a1f1aef8ed.zip cpython-202c99b2e0242a5680668816a65051a1f1aef8ed.tar.gz cpython-202c99b2e0242a5680668816a65051a1f1aef8ed.tar.bz2 |
Remove duplicate type objects from isroutine() and isbuiltin().
Make getmodule() on a module return the module itself.
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r-- | Lib/inspect.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py index b1f723d..f62167b 100644 --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -123,14 +123,12 @@ def isbuiltin(object): __doc__ documentation string __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] + 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, - types.BuiltinMethodType] + types.MethodType, types.BuiltinFunctionType] def getmembers(object, predicate=None): """Return all members of an object as (name, value) pairs sorted by name. @@ -231,6 +229,8 @@ modulesbyfile = {} 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__) try: |