Skip to content

Commit 09c631a

Browse files
committed
reduce import time
1 parent 542738c commit 09c631a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Lib/hmac.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
Implements the HMAC algorithm as described by RFC 2104.
44
"""
55

6-
import warnings as _warnings
76
try:
87
import _hashlib as _hashopenssl
98
except ImportError:
@@ -84,11 +83,15 @@ def _init_old(self, key, msg, digestmod):
8483
if hasattr(self._inner, 'block_size'):
8584
blocksize = self._inner.block_size
8685
if blocksize < 16:
86+
import warnings as _warnings
87+
8788
_warnings.warn('block_size of %d seems too small; using our '
8889
'default of %d.' % (blocksize, self.blocksize),
8990
RuntimeWarning, 2)
9091
blocksize = self.blocksize
9192
else:
93+
import warnings as _warnings
94+
9295
_warnings.warn('No block_size attribute on given digest object; '
9396
'Assuming %d.' % (self.blocksize),
9497
RuntimeWarning, 2)

0 commit comments

Comments
 (0)