MCPcopy Index your code
hub / github.com/python/cpython / _string_to_bytes

Method _string_to_bytes

Lib/mailbox.py:204–212  ·  view source on GitHub ↗
(self, message)

Source from the content-addressed store, hash-verified

202 raise NotImplementedError('Method must be implemented by subclass')
203
204 def _string_to_bytes(self, message):
205 # If a message is not 7bit clean, we refuse to handle it since it
206 # likely came from reading invalid messages in text mode, and that way
207 # lies mojibake.
208 try:
209 return message.encode('ascii')
210 except UnicodeError:
211 raise ValueError("String input must be ASCII-only; "
212 "use bytes or a Message instead")
213
214 # Whether each message must end in a newline
215 _append_newline = False

Callers 3

_dump_messageMethod · 0.95
_install_messageMethod · 0.80
_install_messageMethod · 0.80

Calls 1

encodeMethod · 0.45

Tested by

no test coverage detected