Skip to content

Commit 435ae01

Browse files
committed
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 <[email protected]>
1 parent a0c8cb2 commit 435ae01

File tree

3 files changed

+2
-8
lines changed

3 files changed

+2
-8
lines changed

src/saml2/aes.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
'It will be removed in the next version. '
99
'Use saml2.cryptography.symmetric instead.'
1010
).format(name=__name__, type='module')
11-
12-
_warnings.simplefilter('default')
1311
_warnings.warn(_deprecation_msg, DeprecationWarning)
1412

1513

src/saml2/authn.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import warnings
1+
import warnings as _warnings
22
import logging
33
import six
44
import time
@@ -15,7 +15,6 @@
1515
__author__ = 'rolandh'
1616

1717
logger = logging.getLogger(__name__)
18-
warnings.simplefilter('default')
1918

2019

2120
class AuthnFailure(SAMLError):
@@ -130,7 +129,7 @@ def aes(self):
130129
'This attribute is deprecated. '
131130
'It will be removed in the next version. '
132131
'Use self.symmetric instead.')
133-
warnings.warn(_deprecation_msg, DeprecationWarning)
132+
_warnings.warn(_deprecation_msg, DeprecationWarning)
134133
return self.symmetric
135134

136135
def __call__(self, cookie=None, policy_url=None, logo_url=None,

src/saml2/cryptography/symmetric.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
import cryptography.hazmat.primitives.ciphers as _ciphers
1414

1515

16-
_warnings.simplefilter('default')
17-
18-
1916
class Default(object):
2017
"""The default symmetric cryptography method."""
2118

0 commit comments

Comments
 (0)