[pygobject] make vfuncs work in py3k



commit 0db676fd2296750a46ba0fb069e472da06ecc53a
Author: John (J5) Palmieri <johnp redhat com>
Date:   Wed Aug 18 11:03:32 2010 -0400

    make vfuncs work in py3k
    
    * methods now export __func__ instead of im_func for getting the function
      out of a method closure
    * however classes no longer return unbound methods in py3k and instead
      return the actual function
    * in python 2 we use im_func when getting the function from the vfunc closure
    * in py3k we simply assign vfunc to the function
    
    https://bugzilla.gnome.org/show_bug.cgi?id=615872

 gi/types.py |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/gi/types.py b/gi/types.py
index 7f937f9..4e0e06d 100644
--- a/gi/types.py
+++ b/gi/types.py
@@ -105,10 +105,14 @@ class MetaClassHelper(object):
                             'the method do_%s()' % (base.__info__.get_namespace(),
                                                     base.__info__.get_name(),
                                                     vfunc_info.get_name()))
-                elif vfunc is not None and not \
-                        is_function_in_classes(vfunc.im_func, cls.__bases__):
-                    hook_up_vfunc_implementation(vfunc_info, cls.__gtype__,
-                                                 vfunc)
+                elif vfunc is not None:
+                    function = vfunc
+                    if sys.version_info < (3, 0):
+                        function = vfunc.im_func
+ 
+                    if not is_function_in_classes(function, cls.__bases__):
+                        hook_up_vfunc_implementation(vfunc_info, cls.__gtype__,
+                                                     vfunc)
 
 def is_function_in_classes(function, classes):
     for klass in classes:



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