(self, msg)
| 427 | return s.encode('ascii') |
| 428 | |
| 429 | def _write_headers(self, msg): |
| 430 | # This is almost the same as the string version, except for handling |
| 431 | # strings with 8bit bytes. |
| 432 | for h, v in msg.raw_items(): |
| 433 | folded = self.policy.fold_binary(h, v) |
| 434 | if self.policy.verify_generated_headers: |
| 435 | linesep = self.policy.linesep.encode() |
| 436 | if not folded.endswith(linesep): |
| 437 | raise HeaderWriteError( |
| 438 | f'folded header does not end with {linesep!r}: {folded!r}') |
| 439 | if NEWLINE_WITHOUT_FWSP_BYTES.search(folded.removesuffix(linesep)): |
| 440 | raise HeaderWriteError( |
| 441 | f'folded header contains newline: {folded!r}') |
| 442 | self._fp.write(folded) |
| 443 | # A blank line always separates headers from body |
| 444 | self.write(self._NL) |
| 445 | |
| 446 | def _handle_text(self, msg): |
| 447 | # If the string has surrogates the original source was bytes, so |
nothing calls this directly
no test coverage detected