Skip to content

Commit c24ec76

Browse files
committed
perf(email): optimize max line length calculation
1 parent fa173ac commit c24ec76

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Lib/email/contentmanager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def embedded_body(lines): return linesep.join(lines) + linesep
151151
def normal_body(lines): return b'\n'.join(lines) + b'\n'
152152
if cte is None:
153153
# Use heuristics to decide on the "best" encoding.
154-
if max((len(x) for x in lines), default=0) <= maxlen:
154+
if max(map(len, lines), default=0) <= maxlen:
155155
try:
156156
return '7bit', normal_body(lines).decode('ascii')
157157
except UnicodeDecodeError:
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
:mod:`email`: Ensure policy accepts unlimited line lengths by
2-
treating falsey values as :data:`sys.maxsize`.
1+
:mod:`email`: Fix exception in set_content when encoding text
2+
and max_line_length is set to :const:`0` or :const:`None`
3+
(unlimited).

0 commit comments

Comments
 (0)