From 7e2ed2054cc1ca69a329ad1a2d783f511bb88f43 Mon Sep 17 00:00:00 2001
From: david-sarah <david-sarah@jacaranda.org>
Date: Sun, 31 Oct 2010 09:06:36 -0700
Subject: [PATCH] allmydata/__init__.py: suppress a DeprecationWarning for the
 sha module on importing pycrypto.

---
 src/allmydata/__init__.py | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/allmydata/__init__.py b/src/allmydata/__init__.py
index bfefccbb..96ee8563 100644
--- a/src/allmydata/__init__.py
+++ b/src/allmydata/__init__.py
@@ -8,6 +8,9 @@ community web site: U{http://tahoe-lafs.org/}
 # See http://allmydata.org/trac/tahoe/ticket/859 and
 # http://divmod.org/trac/ticket/2994 .
 import warnings
+warnings.filterwarnings("ignore", category=DeprecationWarning,
+    message="the sha module is deprecated; use the hashlib module instead",
+    append=True)
 warnings.filterwarnings("ignore", category=DeprecationWarning,
     message="object.__new__\(\) takes no parameters",
     append=True)
@@ -17,9 +20,6 @@ warnings.filterwarnings("ignore", category=DeprecationWarning,
 warnings.filterwarnings("ignore", category=DeprecationWarning,
     message="the md5 module is deprecated; use hashlib instead",
     append=True)
-warnings.filterwarnings("ignore", category=DeprecationWarning,
-    message="the sha module is deprecated; use the hashlib module instead",
-    append=True)
 warnings.filterwarnings("ignore", category=DeprecationWarning,
     message="twisted.web.error.NoResource is deprecated since Twisted 9.0.  See twisted.web.resource.NoResource.",
     append=True)
@@ -34,7 +34,9 @@ finally:
     warnings.filters.pop()
     warnings.filters.pop()
     warnings.filters.pop()
-    warnings.filters.pop()
+    # Don't pop the filter for the sha module warning because it is also generated
+    # by pycrypto (which we don't want to import unless needed).
+    # warnings.filters.pop()
 
 # This warning is generated by twisted, PyRex, and possibly other packages,
 # but can happen at any time, not only when they are imported. See
-- 
2.45.2