@@ -1615,9 +1615,10 @@ may be called.
16151615
16161616For cases where you want passive introspection, like documentation tools, this
16171617can be inconvenient. :func: `getattr_static ` has the same signature as :func: `getattr `
1618- but avoids executing code when it fetches attributes.
1618+ (modulo positional-only differences), but avoids executing code when it fetches attributes.
16191619
1620- .. function :: getattr_static(obj, attr, default=None)
1620+ .. function :: getattr_static(obj, attr)
1621+ getattr_static(obj, attr, default)
16211622
16221623 Retrieve attributes without triggering dynamic lookup via the
16231624 descriptor protocol, :meth: `~object.__getattr__ `
@@ -1644,18 +1645,15 @@ for arbitrary getset descriptors invoking these may trigger
16441645code execution::
16451646
16461647 # example code for resolving the builtin descriptor types
1647- class _foo:
1648- __slots__ = ['foo']
1649-
1650- slot_descriptor = type(_foo.foo)
1651- getset_descriptor = type(type(open(__file__)).name)
1648+ slot_descriptor = type(slice.step)
1649+ getset_descriptor = type(property.__dict__['__name__'])
16521650 wrapper_descriptor = type(str.__dict__['__add__'])
16531651 descriptor_types = (slot_descriptor, getset_descriptor, wrapper_descriptor)
16541652
16551653 result = getattr_static(some_object, 'foo')
1656- if type (result) in descriptor_types:
1654+ if isinstance (result, descriptor_types) :
16571655 try:
1658- result = result.__get__()
1656+ result = result.__get__(some_object )
16591657 except AttributeError:
16601658 # descriptors can raise AttributeError to
16611659 # indicate there is no underlying value
0 commit comments