diff options
author | Johan Dahlin <zilch@src.gnome.org> | 2004-04-10 16:39:39 +0000 |
---|---|---|
committer | Johan Dahlin <zilch@src.gnome.org> | 2004-04-10 16:39:39 +0000 |
commit | 287806047cf293b5935f627b2f26ed9a96a7e958 (patch) | |
tree | bb9aa7cf39d3e8e052c9f493261bb76070fe7ca6 /gtk/__init__.py | |
parent | 4d81aa9f5ee5bda405efaa8a7fd1881a4db59bf1 (diff) | |
download | pygtk-287806047cf293b5935f627b2f26ed9a96a7e958.tar.gz |
Move GtkDeprecatedWarning ... Remove global module import and do it in the
* gtk/__init__.py: Move GtkDeprecatedWarning ...
Remove global module import and do it in the class _Deprecated and
delete _Deprecated when done.
(_Deprecated.__repr__): Add.
* gtk/gtkmodule.c: ... here, and rename it to DeprecatedWarning
Diffstat (limited to 'gtk/__init__.py')
-rw-r--r-- | gtk/__init__.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/gtk/__init__.py b/gtk/__init__.py index 0642eb6d..a504ebcf 100644 --- a/gtk/__init__.py +++ b/gtk/__init__.py @@ -59,12 +59,9 @@ gdk.INPUT_WRITE = _gobject.IO_OUT | _gobject.IO_HUP gdk.INPUT_EXCEPTION = _gobject.IO_PRI # Warnings -from warnings import warn as _warn - -class GtkDeprecationWarning(DeprecationWarning): - pass - class _Deprecated: + from warnings import warn + warn = staticmethod(warn) def __init__(self, func, oldname, module=''): self.func = func self.oldname = oldname @@ -73,12 +70,17 @@ class _Deprecated: self.module = 'gtk.' + module else: self.module = 'gtk' - + + def __repr__(self): + return '<deprecated function %s at 0x%x>' % (self.oldname, id(self)) + def __call__(self, *args, **kwargs): message = 'gtk.%s is deprecated, use %s.%s instead' % (self.oldname, self.module, self.name) - _warn(message, GtkDeprecationWarning) + # DeprecationWarning is imported from _gtk, so it's not the same + # as the one found in exceptions. + self.warn(message, DeprecationWarning) return self.func(*args, **kwargs) # old names compatibility ... @@ -92,3 +94,4 @@ create_pixmap_from_xpm = _Deprecated(gdk.pixmap_create_from_xpm, 'pixmap_create_from_xpm', 'gdk') create_pixmap_from_xpm_d = _Deprecated(gdk.pixmap_create_from_xpm_d, 'pixmap_create_from_xpm_d', 'gdk') +del _Deprecated |