[pygobject] Drop gi.overrides.overridefunc()



commit 1dc2bc9f65669417ae1964d70b85f115928b2963
Author: Martin Pitt <martinpitt gnome org>
Date:   Fri Mar 1 14:04:34 2013 +0100

    Drop gi.overrides.overridefunc()
    
    This just adds an unnecessary extra function call and is not really needed.
    Drop it from the only remaining function which uses this (Gtk.main_quit) and
    drop overridefunc().
    
    https://bugzilla.gnome.org/show_bug.cgi?id=686835

 gi/overrides/Gtk.py      |    7 +++----
 gi/overrides/__init__.py |   24 ++----------------------
 2 files changed, 5 insertions(+), 26 deletions(-)
---
diff --git a/gi/overrides/Gtk.py b/gi/overrides/Gtk.py
index b81d8dc..9f0ea0d 100644
--- a/gi/overrides/Gtk.py
+++ b/gi/overrides/Gtk.py
@@ -1489,12 +1489,11 @@ if Gtk._version != '2.0':
     Menu = override(Menu)
     __all__.append('Menu')
 
-_Gtk_main_quit = Gtk.main_quit
 
-
- override(Gtk.main_quit)
 def main_quit(*args):
-    _Gtk_main_quit()
+    Gtk.main_quit()
+
+__all__.append('main_quit')
 
 Gtk.stock_lookup = strip_boolean_result(Gtk.stock_lookup)
 
diff --git a/gi/overrides/__init__.py b/gi/overrides/__init__.py
index 99cb152..bd3af9e 100644
--- a/gi/overrides/__init__.py
+++ b/gi/overrides/__init__.py
@@ -1,4 +1,3 @@
-import types
 import warnings
 import functools
 
@@ -49,32 +48,13 @@ class _Registry(dict):
         self[override_class] = override_class
 
 
-class overridefunc(object):
-    '''decorator for overriding a function'''
-    def __init__(self, func):
-        if not hasattr(func, '__info__'):
-            raise TypeError("func must be an gi function")
-        from ..importer import modules
-        module_name = func.__module__.rsplit('.', 1)[-1]
-        self.module = modules[module_name]._introspection_module
-
-    def __call__(self, func):
-        def wrapper(*args, **kwargs):
-            return func(*args, **kwargs)
-        wrapper.__name__ = func.__name__
-        setattr(self.module, func.__name__, wrapper)
-        return wrapper
-
 registry = _Registry()
 
 
 def override(type_):
     '''Decorator for registering an override'''
-    if isinstance(type_, types.FunctionType):
-        return overridefunc(type_)
-    else:
-        registry.register(type_)
-        return type_
+    registry.register(type_)
+    return type_
 
 
 def deprecated(fn, replacement):


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