diff options
author | Michael Foord <fuzzyman@voidspace.org.uk> | 2010-11-20 16:40:44 (GMT) |
---|---|---|
committer | Michael Foord <fuzzyman@voidspace.org.uk> | 2010-11-20 16:40:44 (GMT) |
commit | e516265bbc75e4bb7fc2ab6eaeb7ad3aef86a938 (patch) | |
tree | 0436a95d2a4ca7b01c238eb6df780798388321df /Doc/library/inspect.rst | |
parent | 6bb9989ae38cd2610e661d6e8899ef58dd9562e3 (diff) | |
download | cpython-e516265bbc75e4bb7fc2ab6eaeb7ad3aef86a938.zip cpython-e516265bbc75e4bb7fc2ab6eaeb7ad3aef86a938.tar.gz cpython-e516265bbc75e4bb7fc2ab6eaeb7ad3aef86a938.tar.bz2 |
Issue 9732: fetch the method resolution order from the type metaclass directly in getattr_static
Diffstat (limited to 'Doc/library/inspect.rst')
-rw-r--r-- | Doc/library/inspect.rst | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/Doc/library/inspect.rst b/Doc/library/inspect.rst index 32e56e5..9a068da 100644 --- a/Doc/library/inspect.rst +++ b/Doc/library/inspect.rst @@ -587,26 +587,14 @@ but avoids executing code when it fetches attributes. that raise AttributeError). It can also return descriptors objects instead of instance members. -There are several cases that will break `getattr_static` or be handled -incorrectly. These are pathological enough not to worry about (i.e. if you do -any of these then you deserve to have everything break anyway): - -* :data:`~object.__dict__` existing (e.g. as a property) but returning the - wrong dictionary or even returning something other than a - dictionary -* classes created with :data:`~object.__slots__` that have the `__slots__` - member deleted from the class, or a fake `__slots__` attribute - attached to the instance, or any other monkeying with - `__slots__` -* type objects that lie about their :term:`MRO` - -.. note:: - - Classes that override :data:`~object.__mro__` as a property will have this - code executed by `getattr_static`. - -Descriptors are not resolved (for example slot descriptors or -getset descriptors on objects implemented in C). The descriptor +The only known case that can cause `getattr_static` to trigger code execution, +and cause it to return incorrect results (or even break), is where a class uses +:data:`~object.__slots__` and provides a `__dict__` member using a property or +descriptor. If you find other cases please report them so they can be fixed +or documented. + +`getattr_static` does not resolve descriptors, for example slot descriptors or +getset descriptors on objects implemented in C. The descriptor object is returned instead of the underlying attribute. You can handle these with code like the following. Note that |