code: def instance_dir(obj):  # pragma: py3 no cover
      
      d = dict()
      d.update(obj.__dict__)
      d.update(class_dir(obj.__class__))
      result = sorted(d.keys())
      return result
docs: Vanilla implementation of built-in dir() for PY2 to help with overriding __dir__.
      Based on implementation of dir() in pypy.