Issue #17276: MD5 as default digestmod for HMAC is deprecated. The HMAC
module supports digestmod names, e.g. hmac.HMAC('sha1').
diff --git a/Lib/hmac.py b/Lib/hmac.py
index d13b205..873327b 100644
--- a/Lib/hmac.py
+++ b/Lib/hmac.py
@@ -5,6 +5,7 @@
 
 import warnings as _warnings
 from _operator import _compare_digest as compare_digest
+import hashlib as _hashlib
 
 trans_5C = bytes((x ^ 0x5C) for x in range(256))
 trans_36 = bytes((x ^ 0x36) for x in range(256))
@@ -28,8 +29,11 @@
         key:       key for the keyed hash object.
         msg:       Initial input for the hash, if provided.
         digestmod: A module supporting PEP 247.  *OR*
-                   A hashlib constructor returning a new hash object.
+                   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.
 
         Note: key and msg must be a bytes or bytearray objects.
         """
@@ -38,11 +42,14 @@
             raise TypeError("key: expected bytes or bytearray, but got %r" % type(key).__name__)
 
         if digestmod is None:
-            import hashlib
-            digestmod = hashlib.md5
+            _warnings.warn("HMAC() without an explicit digestmod argument "
+                           "is deprecated.", PendingDeprecationWarning, 2)
+            digestmod = _hashlib.md5
 
         if callable(digestmod):
             self.digest_cons = digestmod
+        elif isinstance(digestmod, str):
+            self.digest_cons = lambda d=b'': _hashlib.new(digestmod, d)
         else:
             self.digest_cons = lambda d=b'': digestmod.new(d)