kuuko pushed a commit to branch master.

http://git.enlightenment.org/bindings/python/python-efl.git/commit/?id=f2b22e94bb601e7a461d7302636626fb062fbadf

commit f2b22e94bb601e7a461d7302636626fb062fbadf
Author: Kai Huuhko <kai.huu...@gmail.com>
Date:   Sun Nov 24 17:56:08 2013 +0200

    Eo: Change _register_decorated_callbacks to not use hasattr/getattr
    
    They actually get the value of a property, leading to unexpected
    behavior. Iterate the class dict instead.
---
 efl/eo/efl.eo.pyx  | 10 ++++++----
 include/efl.eo.pxd |  2 +-
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/efl/eo/efl.eo.pyx b/efl/eo/efl.eo.pyx
index fdbeecd..df74db4 100644
--- a/efl/eo/efl.eo.pyx
+++ b/efl/eo/efl.eo.pyx
@@ -148,7 +148,7 @@ cdef object object_from_instance(cEo *obj):
     return o
 
 
-cdef void _register_decorated_callbacks(object obj):
+cdef void _register_decorated_callbacks(Eo obj):
     """
 
     Search every attrib of the pyobj for a __decorated_callbacks__ object,
@@ -158,10 +158,12 @@ cdef void _register_decorated_callbacks(object obj):
 
     """
     cdef object attr_name, attrib, func_name, func
+    cdef type cls = type(obj)
 
-    for attr_name in dir(obj):
-        attrib = getattr(obj, attr_name)
-        if hasattr(attrib, "__decorated_callbacks__"):
+    # XXX: This whole thing is really slow. Can we do it better?
+
+    for attr_name, attrib in cls.__dict__.iteritems():
+        if "__decorated_callbacks__" in dir(attrib):
             for (func_name, *args) in getattr(attrib, 
"__decorated_callbacks__"):
                 func = getattr(obj, func_name)
                 func(*args)
diff --git a/include/efl.eo.pxd b/include/efl.eo.pxd
index 7bebc7d..a7f9a94 100644
--- a/include/efl.eo.pxd
+++ b/include/efl.eo.pxd
@@ -38,4 +38,4 @@ cdef:
     void _object_mapping_register(char *name, object cls) except *
     void _object_mapping_unregister(char *name)
 
-    void _register_decorated_callbacks(object obj)
+    void _register_decorated_callbacks(Eo obj)

-- 


Reply via email to