bpo-33604: Remove Pending from hmac Deprecation warning. (GH-7062)

bpo-33604: Bump removal notice from 3.6 to 3.8 and change PendingDeprecationWarning to DeprecationWarning as we had intended to do earlier...
(cherry picked from commit 8bb0b5b03c)

Co-authored-by: Matthias Bussonnier <bussonniermatthias@gmail.com>
This commit is contained in:
Miss Islington (bot) 2018-05-22 16:40:44 -07:00 committed by GitHub
parent cd57b48ef9
commit 2751dccca4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 6 deletions

View file

@ -27,7 +27,7 @@ This module implements the HMAC algorithm as described by :rfc:`2104`.
Parameter *msg* can be of any type supported by :mod:`hashlib`. Parameter *msg* can be of any type supported by :mod:`hashlib`.
Parameter *digestmod* can be the name of a hash algorithm. Parameter *digestmod* can be the name of a hash algorithm.
.. deprecated:: 3.4 .. deprecated-removed:: 3.4 3.8
MD5 as implicit default digest for *digestmod* is deprecated. MD5 as implicit default digest for *digestmod* is deprecated.

View file

@ -39,8 +39,8 @@ class HMAC:
A hashlib constructor returning a new hash object. *OR* A hashlib constructor returning a new hash object. *OR*
A hash name suitable for hashlib.new(). A hash name suitable for hashlib.new().
Defaults to hashlib.md5. Defaults to hashlib.md5.
Implicit default to hashlib.md5 is deprecated and will be Implicit default to hashlib.md5 is deprecated since Python
removed in Python 3.6. 3.4 and will be removed in Python 3.8.
Note: key and msg must be a bytes or bytearray objects. Note: key and msg must be a bytes or bytearray objects.
""" """
@ -50,7 +50,9 @@ class HMAC:
if digestmod is None: if digestmod is None:
_warnings.warn("HMAC() without an explicit digestmod argument " _warnings.warn("HMAC() without an explicit digestmod argument "
"is deprecated.", PendingDeprecationWarning, 2) "is deprecated since Python 3.4, and will be removed "
"in 3.8",
DeprecationWarning, 2)
digestmod = _hashlib.md5 digestmod = _hashlib.md5
if callable(digestmod): if callable(digestmod):

View file

@ -12,7 +12,7 @@ def ignore_warning(func):
def wrapper(*args, **kwargs): def wrapper(*args, **kwargs):
with warnings.catch_warnings(): with warnings.catch_warnings():
warnings.filterwarnings("ignore", warnings.filterwarnings("ignore",
category=PendingDeprecationWarning) category=DeprecationWarning)
return func(*args, **kwargs) return func(*args, **kwargs)
return wrapper return wrapper
@ -303,7 +303,7 @@ class TestVectorsTestCase(unittest.TestCase):
self.fail('Expected warning about small block_size') self.fail('Expected warning about small block_size')
def test_with_digestmod_warning(self): def test_with_digestmod_warning(self):
with self.assertWarns(PendingDeprecationWarning): with self.assertWarns(DeprecationWarning):
key = b"\x0b" * 16 key = b"\x0b" * 16
data = b"Hi There" data = b"Hi There"
digest = "9294727A3638BB1C13F48EF8158BFC9D" digest = "9294727A3638BB1C13F48EF8158BFC9D"

View file

@ -0,0 +1 @@
Update HMAC md5 default to a DeprecationWarning, bump removal to 3.8.