Skip to content

Commit

Permalink
Remove removesuffix
Browse files Browse the repository at this point in the history
  • Loading branch information
ambv committed Aug 2, 2024
1 parent 7725541 commit c42cbdc
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Lib/email/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,10 @@ def _write_headers(self, msg):
if not folded.endswith(self.policy.linesep):
raise HeaderWriteError(
f'folded header does not end with {linesep!r}: {folded!r}')
if NEWLINE_WITHOUT_FWSP.search(folded.removesuffix(linesep)):
folded_no_linesep = folded
if folded.endswith(linesep):
folded_no_linesep = folded[:-len(linesep)]
if NEWLINE_WITHOUT_FWSP.search(folded_no_linesep):
raise HeaderWriteError(
f'folded header contains newline: {folded!r}')
self.write(folded)
Expand Down

0 comments on commit c42cbdc

Please sign in to comment.