diff options
author | Brett Cannon <brett@python.org> | 2022-10-06 22:40:22 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-06 22:40:22 (GMT) |
commit | e1c4d56fdde28728c37de855edbb463fa0d7f95d (patch) | |
tree | b4c3a715e975f6349a8b07d856965fffb911f26d /Lib/inspect.py | |
parent | f8edc6ff531bb98858185857513371f14519ed1d (diff) | |
download | cpython-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.py | 21 |
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): |