summaryrefslogtreecommitdiffstats
path: root/Lib/inspect.py
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2022-10-06 22:40:22 (GMT)
committerGitHub <noreply@github.com>2022-10-06 22:40:22 (GMT)
commite1c4d56fdde28728c37de855edbb463fa0d7f95d (patch)
treeb4c3a715e975f6349a8b07d856965fffb911f26d /Lib/inspect.py
parentf8edc6ff531bb98858185857513371f14519ed1d (diff)
downloadcpython-e1c4d56fdde28728c37de855edbb463fa0d7f95d.zip
cpython-e1c4d56fdde28728c37de855edbb463fa0d7f95d.tar.gz
cpython-e1c4d56fdde28728c37de855edbb463fa0d7f95d.tar.bz2
gh-65961: Do not rely solely on `__cached__` (GH-97990)
Make sure `__spec__.cached` (at minimum) can be used.
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r--Lib/inspect.py21
1 files changed, 3 insertions, 18 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py
index 498ee7a..8a107a8 100644
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -281,30 +281,15 @@ def get_annotations(obj, *, globals=None, locals=None, eval_str=False):
# ----------------------------------------------------------- type-checking
def ismodule(object):
- """Return true if the object is a module.
-
- Module objects provide these attributes:
- __cached__ pathname to byte compiled file
- __doc__ documentation string
- __file__ filename (missing for built-in modules)"""
+ """Return true if the object is a module."""
return isinstance(object, types.ModuleType)
def isclass(object):
- """Return true if the object is a class.
-
- Class objects provide these attributes:
- __doc__ documentation string
- __module__ name of module in which this class was defined"""
+ """Return true if the object is a class."""
return isinstance(object, type)
def ismethod(object):
- """Return true if the object is an instance method.
-
- Instance method objects provide these attributes:
- __doc__ documentation string
- __name__ name with which this method was defined
- __func__ function object containing implementation of method
- __self__ instance to which this method is bound"""
+ """Return true if the object is an instance method."""
return isinstance(object, types.MethodType)
def ismethoddescriptor(object):