[pygobject] Change __dir__() to report all the attributes that __getattr__ supports



commit 52a298cc0f05ceec96457f17f9a801e9838fb757
Author: Laszlo Pandy <laszlok2 gmail com>
Date:   Tue Jan 11 19:26:50 2011 +0100

    Change __dir__() to report all the attributes that __getattr__ supports
    
    Change DynamicModule.__dir__() to return the local class members as well as the
    typelib attributes.
    
    Change DynamicModule.__getattr__() to call IntrospectionModule.__getattr__()
    directly, so that it won't inadvertently return class attributes from
    IntrospectionModule.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=639229

 gi/module.py |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/gi/module.py b/gi/module.py
index 1d48287..2084442 100644
--- a/gi/module.py
+++ b/gi/module.py
@@ -217,6 +217,7 @@ class DynamicModule(object):
         self.introspection_module = None
         self._version = None
         self._overrides_module = None
+        self.__path__ = None
 
     def require_version(self, version):
         if self.introspection_module is not None and \
@@ -250,9 +251,12 @@ class DynamicModule(object):
             if key in registry:
                 return registry[key]
 
-        return getattr(self.introspection_module, name)
+        return self.introspection_module.__getattr__(name)
 
     def __dir__ (self):
         repository.require(self._namespace, self._version)
-        attribs_list = repository.get_infos(self._namespace)
-        return list(map(lambda x: x.get_name(), attribs_list))
+        
+        namespace_infos = repository.get_infos(self._namespace)
+        result = [info.get_name() for info in namespace_infos]
+        result.extend(self.__dict__.keys())
+        return result



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]