summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Kanakarakis <ivan.kanak@gmail.com>2019-01-07 01:14:39 +0200
committerIvan Kanakarakis <ivan.kanak@gmail.com>2019-01-07 01:14:39 +0200
commit435ae0176f917b089f6ed7de9c866b7b99ad8097 (patch)
tree0d178465055b77c9e0cd5e4076660675a6a6300b
parenta0c8cb289b03c700ca166ab282719976cb273a91 (diff)
downloadpysaml2-435ae0176f917b089f6ed7de9c866b7b99ad8097.tar.gz
Do not hardcode the warning filter
The application should control whether warnings should be visible or not. By hardcoding the simplefilter we turn on warnings' visibility for all modules that follow. Removing this allows the application code to decide if warnings should be shown. To enable warnings through the command line pass -Wd to the python interpreter. Quoting the python warnings module documentation[0]: > You can do this from the command-line by passing -Wd to the interpreter (this > is shorthand for -W default). This enables default handling for all warnings, > including those that are ignored by default. To change what action is taken > for encountered warnings you simply change what argument is passed to -W, > e.g. -W error. See the -W flag for more details on what is possible. [0]: https://docs.python.org/2/library/warnings.html#updating-code-for-new-versions-of-python Signed-off-by: Ivan Kanakarakis <ivan.kanak@gmail.com>
-rw-r--r--src/saml2/aes.py2
-rw-r--r--src/saml2/authn.py5
-rw-r--r--src/saml2/cryptography/symmetric.py3
3 files changed, 2 insertions, 8 deletions
diff --git a/src/saml2/aes.py b/src/saml2/aes.py
index d58e34e5..6f37fb33 100644
--- a/src/saml2/aes.py
+++ b/src/saml2/aes.py
@@ -8,8 +8,6 @@ _deprecation_msg = (
'It will be removed in the next version. '
'Use saml2.cryptography.symmetric instead.'
).format(name=__name__, type='module')
-
-_warnings.simplefilter('default')
_warnings.warn(_deprecation_msg, DeprecationWarning)
diff --git a/src/saml2/authn.py b/src/saml2/authn.py
index a0141419..fd16d8c9 100644
--- a/src/saml2/authn.py
+++ b/src/saml2/authn.py
@@ -1,4 +1,4 @@
-import warnings
+import warnings as _warnings
import logging
import six
import time
@@ -15,7 +15,6 @@ from six.moves.urllib.parse import urlencode, parse_qs, urlsplit
__author__ = 'rolandh'
logger = logging.getLogger(__name__)
-warnings.simplefilter('default')
class AuthnFailure(SAMLError):
@@ -130,7 +129,7 @@ class UsernamePasswordMako(UserAuthnMethod):
'This attribute is deprecated. '
'It will be removed in the next version. '
'Use self.symmetric instead.')
- warnings.warn(_deprecation_msg, DeprecationWarning)
+ _warnings.warn(_deprecation_msg, DeprecationWarning)
return self.symmetric
def __call__(self, cookie=None, policy_url=None, logo_url=None,
diff --git a/src/saml2/cryptography/symmetric.py b/src/saml2/cryptography/symmetric.py
index 16df21f3..cf7988e6 100644
--- a/src/saml2/cryptography/symmetric.py
+++ b/src/saml2/cryptography/symmetric.py
@@ -13,9 +13,6 @@ import cryptography.hazmat.backends as _backends
import cryptography.hazmat.primitives.ciphers as _ciphers
-_warnings.simplefilter('default')
-
-
class Default(object):
"""The default symmetric cryptography method."""