MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / set_payload

Method set_payload

tools/python-3.11.9-amd64/Lib/email/message.py:331–349  ·  view source on GitHub ↗

Set the payload to the given value. Optional charset sets the message's default character set. See set_charset() for details.

(self, payload, charset=None)

Source from the content-addressed store, hash-verified

329 return payload
330
331 def set_payload(self, payload, charset=None):
332 """Set the payload to the given value.
333
334 Optional charset sets the message's default character set. See
335 set_charset() for details.
336 """
337 if hasattr(payload, 'encode'):
338 if charset is None:
339 self._payload = payload
340 return
341 if not isinstance(charset, Charset):
342 charset = Charset(charset)
343 payload = payload.encode(charset.output_charset, 'surrogateescape')
344 if hasattr(payload, 'decode'):
345 self._payload = payload.decode('ascii', 'surrogateescape')
346 else:
347 self._payload = payload
348 if charset is not None:
349 self.set_charset(charset)
350
351 def set_charset(self, charset):
352 """Set the charset of the payload to a given character set.

Callers 11

_parsegenMethod · 0.80
encode_base64Function · 0.80
encode_quopriFunction · 0.80
_handle_textMethod · 0.80
set_text_contentFunction · 0.80
set_message_contentFunction · 0.80
set_bytes_contentFunction · 0.80
__init__Method · 0.80
__init__Method · 0.80
__init__Method · 0.80
__init__Method · 0.80

Calls 4

set_charsetMethod · 0.95
CharsetClass · 0.85
encodeMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected