From: Daira Hopwood Date: Thu, 5 Sep 2013 16:46:01 +0000 (+0100) Subject: Thu Jun 14 22:23:08 BST 2012 david-sarah@jacaranda.org X-Git-Url: https://git.rkrishnan.org/%5B/frontends/(%5B%5E?a=commitdiff_plain;h=a6da0db05cf03b42e4145a9759b15c80afcdeb04;p=tahoe-lafs%2Ftahoe-lafs.git Thu Jun 14 22:23:08 BST 2012 david-sarah@jacaranda.org * Suppress DeprecationWarning about twisted.internet.interfaces.IFinishableConsumer. This also unifies the handling of DeprecationWarnings that need to be suppressed globally. refs #1295 --- diff --git a/src/allmydata/__init__.py b/src/allmydata/__init__.py index 4ddea757..4b70273e 100644 --- a/src/allmydata/__init__.py +++ b/src/allmydata/__init__.py @@ -144,7 +144,7 @@ def normalized_version(verstr, what=None): def get_package_versions_and_locations(): import warnings - from _auto_deps import package_imports, deprecation_messages, \ + from _auto_deps import package_imports, global_deprecation_messages, deprecation_messages, \ user_warning_messages, runtime_warning_messages, warning_imports def package_dir(srcfile): @@ -155,16 +155,10 @@ def get_package_versions_and_locations(): # or any other bug that causes sys.path to be set up incorrectly. Therefore we # must import the packages in order to check their versions and paths. - # This warning is generated by twisted, PyRex, and possibly other packages, - # but can happen at any time, not only when they are imported. See ticket #1129. - warnings.filterwarnings("ignore", category=DeprecationWarning, - message="BaseException.message has been deprecated as of Python 2.6", - append=True) - # This is to suppress various DeprecationWarnings, UserWarnings, and RuntimeWarnings - # (listed in _auto_deps.py) that occur when modules are imported. + # (listed in _auto_deps.py). - for msg in deprecation_messages: + for msg in global_deprecation_messages + deprecation_messages: warnings.filterwarnings("ignore", category=DeprecationWarning, message=msg, append=True) for msg in user_warning_messages: warnings.filterwarnings("ignore", category=UserWarning, message=msg, append=True) @@ -177,6 +171,7 @@ def get_package_versions_and_locations(): except ImportError: pass finally: + # Leave suppressions for global_deprecation_messages active. for ign in runtime_warning_messages + user_warning_messages + deprecation_messages: warnings.filters.pop() diff --git a/src/allmydata/_auto_deps.py b/src/allmydata/_auto_deps.py index 37acb4b2..97e9c536 100644 --- a/src/allmydata/_auto_deps.py +++ b/src/allmydata/_auto_deps.py @@ -108,6 +108,16 @@ def require_more(): require_more() + +# These are suppressed globally: + +global_deprecation_messages = [ + "BaseException.message has been deprecated as of Python 2.6", + "twisted.internet.interfaces.IFinishableConsumer was deprecated in Twisted 11.1.0: Please use IConsumer (and IConsumer.unregisterProducer) instead.", +] + +# These are suppressed while importing dependencies: + deprecation_messages = [ "the sha module is deprecated; use the hashlib module instead", "object.__new__\(\) takes no parameters",