[warnings] explicitly ask to show DeprecationWarning in debug mode (closes #1942760) stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 22 Sep 2011 10:02:17 +0200
branchstable
changeset 7822 ce8a4de2ecf1
parent 7820 2c73fc529a20
child 7823 5f145462e041
[warnings] explicitly ask to show DeprecationWarning in debug mode (closes #1942760) as python 2.7 don't show DeprecationWarning by default
cwconfig.py
--- a/cwconfig.py	Wed Sep 21 19:04:33 2011 +0200
+++ b/cwconfig.py	Thu Sep 22 10:02:17 2011 +0200
@@ -144,7 +144,8 @@
 from threading import Lock
 from os.path import (exists, join, expanduser, abspath, normpath,
                      basename, isdir, dirname, splitext)
-from warnings import warn
+from warnings import warn, filterwarnings
+
 from logilab.common.decorators import cached, classproperty
 from logilab.common.deprecation import deprecated
 from logilab.common.logging_ext import set_log_methods, init_log
@@ -696,6 +697,9 @@
         return vregpath
 
     def __init__(self, debugmode=False):
+        if debugmode:
+            # in python 2.7, DeprecationWarning are not shown anymore by default
+            filterwarnings('default', category=DeprecationWarning)
         register_stored_procedures()
         self._cubes = None
         super(CubicWebNoAppConfiguration, self).__init__()