Skip to content

Commit e2df647

Browse files
committed
simplify checks
1 parent 3ea0582 commit e2df647

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Lib/smtplib.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,16 @@ def _fix_eols(data):
179179
return re.sub(r'(?:\r\n|\n|\r(?!\n))', CRLF, data)
180180

181181

182-
# CRAM-MD5 may be supported by the server but not by us
183-
# if HMAC-MD5 is not supported.
182+
# Use unbounded LRU cache instead of global variable to ease mocking.
184183
@functools.cache
185184
def _have_cram_md5_support():
185+
"""Check if CRAM-MD5 is supported by the host.
186+
187+
Note that CRAM-MD5 may be supported by the server
188+
but not by the client if HMAC-MD5 is not supported.
189+
"""
186190
try:
187-
hmac.new(b'', b'', 'md5').hexdigest()
191+
hmac.digest(b'', b'', 'md5')
188192
return True
189193
except ValueError:
190194
return False

0 commit comments

Comments
 (0)