Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.7] bpo-33604: Remove Pending from hmac Deprecation warning. (GH-7062) #7065

Merged
merged 1 commit into from
May 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Doc/library/hmac.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 *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.


Expand Down
8 changes: 5 additions & 3 deletions Lib/hmac.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ def __init__(self, key, msg = None, digestmod = None):
A hashlib constructor returning a new hash object. *OR*
A hash name suitable for hashlib.new().
Defaults to hashlib.md5.
Implicit default to hashlib.md5 is deprecated and will be
removed in Python 3.6.
Implicit default to hashlib.md5 is deprecated since Python
3.4 and will be removed in Python 3.8.

Note: key and msg must be a bytes or bytearray objects.
"""
Expand All @@ -50,7 +50,9 @@ def __init__(self, key, msg = None, digestmod = None):

if digestmod is None:
_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

if callable(digestmod):
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_hmac.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def ignore_warning(func):
def wrapper(*args, **kwargs):
with warnings.catch_warnings():
warnings.filterwarnings("ignore",
category=PendingDeprecationWarning)
category=DeprecationWarning)
return func(*args, **kwargs)
return wrapper

Expand Down Expand Up @@ -303,7 +303,7 @@ def digest(self):
self.fail('Expected warning about small block_size')

def test_with_digestmod_warning(self):
with self.assertWarns(PendingDeprecationWarning):
with self.assertWarns(DeprecationWarning):
key = b"\x0b" * 16
data = b"Hi There"
digest = "9294727A3638BB1C13F48EF8158BFC9D"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update HMAC md5 default to a DeprecationWarning, bump removal to 3.8.