bpo-40597: Allow email.contextmanager set_content() to set a null string. (GH-20542)

This commit is contained in:
Mark Sapiro
2020-07-08 14:00:35 -07:00
committed by GitHub
parent 61fc23ca10
commit 4fa61a7732
3 changed files with 15 additions and 1 deletions

View File

@@ -146,7 +146,7 @@ def _encode_text(string, charset, cte, policy):
def normal_body(lines): return b'\n'.join(lines) + b'\n'
if cte==None:
# Use heuristics to decide on the "best" encoding.
if max(len(x) for x in lines) <= policy.max_line_length:
if max((len(x) for x in lines), default=0) <= policy.max_line_length:
try:
return '7bit', normal_body(lines).decode('ascii')
except UnicodeDecodeError: