summaryrefslogtreecommitdiffstats
path: root/Doc/library/hmac.rst
diff options
context:
space:
mode:
authorGregory P. Smith <greg@krypto.org>2019-10-18 03:30:42 (GMT)
committerGitHub <noreply@github.com>2019-10-18 03:30:42 (GMT)
commitf33c57d5c780da1500619f548585792bb5b750ee (patch)
treed73bb962abdea1b31e27dc01c070a595a4f74fb5 /Doc/library/hmac.rst
parentd8ca2354ed30c12b9ce37c4535222b700a727b32 (diff)
downloadcpython-f33c57d5c780da1500619f548585792bb5b750ee.zip
cpython-f33c57d5c780da1500619f548585792bb5b750ee.tar.gz
cpython-f33c57d5c780da1500619f548585792bb5b750ee.tar.bz2
bpo-33604: Raise TypeError on missing hmac arg. (GH-16805)
Also updates the documentation to clarify the situation surrounding the digestmod parameter that is required despite its position in the argument list as of 3.8.0 as well as removing old python2 era references to "binary strings". We indavertently had this raise ValueError in 3.8.0 for the missing arg. This is not considered an API change as no reasonable code would be catching this missing argument error in order to handle it.
Diffstat (limited to 'Doc/library/hmac.rst')
-rw-r--r--Doc/library/hmac.rst8
1 files changed, 5 insertions, 3 deletions
diff --git a/Doc/library/hmac.rst b/Doc/library/hmac.rst
index dc994b0..57ac8bb 100644
--- a/Doc/library/hmac.rst
+++ b/Doc/library/hmac.rst
@@ -14,12 +14,13 @@
This module implements the HMAC algorithm as described by :rfc:`2104`.
-.. function:: new(key, msg=None, digestmod=None)
+.. function:: new(key, msg=None, digestmod='')
Return a new hmac object. *key* is a bytes or bytearray object giving the
secret key. If *msg* is present, the method call ``update(msg)`` is made.
*digestmod* is the digest name, digest constructor or module for the HMAC
- object to use. It supports any name suitable to :func:`hashlib.new`.
+ object to use. It may be any name suitable to :func:`hashlib.new`.
+ Despite its argument position, it is required.
.. versionchanged:: 3.4
Parameter *key* can be a bytes or bytearray object.
@@ -28,6 +29,8 @@ This module implements the HMAC algorithm as described by :rfc:`2104`.
.. deprecated-removed:: 3.4 3.8
MD5 as implicit default digest for *digestmod* is deprecated.
+ The digestmod parameter is now required. Pass it as a keyword
+ argument to avoid awkwardness when you do not have an initial msg.
.. function:: digest(key, msg, digest)
@@ -127,7 +130,6 @@ This module also provides the following helper function:
a timing attack could theoretically reveal information about the
types and lengths of *a* and *b*—but not their values.
-
.. versionadded:: 3.3