[pygobject] Change base class of PyGIDeprecationWarning based on minor version



commit 669e15c35213dbce6ceb0a4a3d474aae620910ce
Author: Simon Feltman <sfeltman src gnome org>
Date:   Sun Mar 17 15:37:09 2013 -0700

    Change base class of PyGIDeprecationWarning based on minor version
    
    Use RuntimeWarning as the base class of PyGIDeprecationWarning
    for unstable (odd minor version) and use DeprecationWarning for
    stable (even minor version). This is so PyGObject deprecations
    behave the same as regular Python deprecations in stable releases.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=696011

 gi/__init__.py |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/gi/__init__.py b/gi/__init__.py
index 70a4917..e8c12db 100644
--- a/gi/__init__.py
+++ b/gi/__init__.py
@@ -83,7 +83,15 @@ def get_required_version(namespace):
     return _versions.get(namespace, None)
 
 
-# note, DeprecationWarning would be more suitable as a base, but this
-# unhelpfully isn't shown by default and thus useless
-class PyGIDeprecationWarning(RuntimeWarning):
+# Use RuntimeWarning as the base class of PyGIDeprecationWarning
+# for unstable (odd minor version) and use DeprecationWarning for
+# stable (even minor version). This is so PyGObject deprecations
+# behave the same as regular Python deprecations in stable releases.
+if version_info[1] % 2:
+    _DeprecationWarningBase = RuntimeWarning
+else:
+    _DeprecationWarningBase = DeprecationWarning
+
+
+class PyGIDeprecationWarning(_DeprecationWarningBase):
     pass


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