From 717837a91498f9f928a0affbfa39d8cd68de5ca1 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 1 May 2007 13:26:51 +0100 Subject: [PATCH] Simplify dbus_bindings backwards compatibility glue --- dbus/_dbus.py | 26 ++++---------------------- dbus/dbus_bindings.py | 13 ++++++++++++- dbus_bindings.py | 4 ---- 3 files changed, 16 insertions(+), 27 deletions(-) diff --git a/dbus/_dbus.py b/dbus/_dbus.py index 12aff2c..d46aa9b 100644 --- a/dbus/_dbus.py +++ b/dbus/_dbus.py @@ -234,37 +234,19 @@ class StarterBus(Bus): mainloop=mainloop) -_dbus_bindings_warning = DeprecationWarning("""\ -The dbus_bindings module is deprecated and will go away soon. - -dbus-python 0.80 provides only a partial emulation of the old -dbus_bindings, which was never meant to be public API. - -Most uses of dbus_bindings are applications catching the exception -dbus.dbus_bindings.DBusException. You should use dbus.DBusException -instead (this is compatible with all dbus-python versions since 0.40.2). - -If you need additional public API, please contact the maintainers via -. -""") - if 'DBUS_PYTHON_NO_DEPRECATED' not in os.environ: class _DBusBindingsEmulation: """A partial emulation of the dbus_bindings module.""" - _module = None def __str__(self): return '_DBusBindingsEmulation()' def __repr__(self): return '_DBusBindingsEmulation()' def __getattr__(self, attr): - if self._module is None: - from warnings import warn as _warn - _warn(_dbus_bindings_warning, DeprecationWarning, stacklevel=2) - - import dbus.dbus_bindings as m - self._module = m - return getattr(self._module, attr) + global dbus_bindings + import dbus.dbus_bindings as m + dbus_bindings = m + return getattr(m, attr) dbus_bindings = _DBusBindingsEmulation() """Deprecated, don't use.""" diff --git a/dbus/dbus_bindings.py b/dbus/dbus_bindings.py index a412f41..050a4e1 100644 --- a/dbus/dbus_bindings.py +++ b/dbus/dbus_bindings.py @@ -1,7 +1,18 @@ # Backwards-compatibility with the old dbus_bindings. from warnings import warn as _warn -from dbus._dbus import _dbus_bindings_warning + +_dbus_bindings_warning = DeprecationWarning("""\ +The dbus_bindings module is not public API and will go away soon. + +Most uses of dbus_bindings are applications catching the exception +dbus.dbus_bindings.DBusException. You should use dbus.DBusException +instead (this is compatible with all dbus-python versions since 0.40.2). + +If you need additional public API, please contact the maintainers via +. +""") + _warn(_dbus_bindings_warning, DeprecationWarning, stacklevel=2) # Exceptions diff --git a/dbus_bindings.py b/dbus_bindings.py index 836b211..f6dcf81 100644 --- a/dbus_bindings.py +++ b/dbus_bindings.py @@ -1,5 +1 @@ -from warnings import warn as _warn -from dbus._dbus import _dbus_bindings_warning -_warn(_dbus_bindings_warning, DeprecationWarning, stacklevel=2) - from dbus.dbus_bindings import * -- 2.11.4.GIT